澳门新葡萄京官网首页 1

澳门新葡萄京官网首页PHP静态分析与跨站脚本检测

最近在看PHP静态分析与跨站脚本检测的东西,用的是维也纳大学一个博士生做出来的Pixy,这个东西是开源的,而且也作了好几年了,功能逐渐增强。现在这个3.0.3版本里边有225个程序,Checker是主程序,现在所有结果都是显示在命令行的,如果被检测程序大,结果很多,当然是个问题。而我要做的大概是将其显示到GUI中去,并且改进它本身呈鼓里边一些不足的地方。从寒假就开始看他的程序,寒假里边没有怎么搞明白,又冷,手生冻疮了。回来以后,从头开始看吧,分析那一部分不是很明白,但是看到后来,检测漏洞的时候,我想暂时不管它存储的结构什么,反正都是Node之类的东西,看他是怎么检测的,有的细节地方那个暂时翻过去,结果感觉比前边analysze部分简单得多了,连那些存储结构什么的都明白些了。当然也看他的论文,论文换了一个寒假看完,没弄明白,像Cfg这些东西在论文中有,但是显示不出来,没有直观的感觉,不爽。所以这两天忙着弄了个GUI界面来显示这个Cfg控制流图,麻烦了一点,不过总算是出来了,看看好像也没有多大问题,献丑在这里了。另外,本来是自己使用的,有的地方考虑不周也无所谓,自己再调调就行了。共有3个文件,第一个是Coor.java,保存每个节点的坐标以及其子节点坐标:
packageat.ac.tuwien.infosys.;importjava.util.*;publicclassCoor…{privateintx;privateinty;privateListCoorcoors;publicCoor(intx,inty)…{this.coors=newLinkedListCoor();this.x=x;this.y=y;}publicintgetX()…{returnthis.x;}publicintgetY()…{returnthis.y;}publicListCoorgetCoors()…{returnthis.coors;}publicvoidaddCoor(Coorcoor)…{this.coors.add(coor);}publicbooleanequals(Coorcoor)…{if(coor.getX()==this.xcoor.getY()==y)…{returntrue;}returnfalse;}publicbooleancontains(Coorc)…{for(Coorcoor:this.coors)…{if(coor.getX()==c.getX()coor.getY()==c.getY())…{returntrue;}}returnfalse;}}第二个是DrawPanel.java,负责画图的组件:packageat.ac.tuwien.infosys.;importat.ac.tuwien.infosys.;importat.ac.tuwien.infosys.*;importjava.util.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;/***//****@authorAdministrator*/publicclassDrawPanelextendsJPanel…{privatejava.util.ListCfgNodecfgList;privatejava.util.ListCoorcoorList;/***//**CreatesanewinstanceofOvalJPanel*/publicDrawPanel(java.util.ListCfgNodecfgList,java.util.ListCoorcoorList)…{this.cfgList=cfgList;this.coorList=coorList;}//在面板上绘制图形publicvoidpaintComponent(Graphicsg)…{for(inti=0;ithis.cfgList.size();i++)…{CfgNodecfgNode=this.cfgList.get(i);Coorcoor=this.coorList.get(i);intx=coor.getX();inty=coor.getY();g.setColor(Color.red);g.drawOval(x-50,y-15,100,30);g.setColor(Color.blue);g.drawString(cfgNode.toString(),x-30,y-5);g.drawString(Loc:+String.valueOf(cfgNode.getOrigLineno()),x,y+10);java.util.ListCoorcoors=coor.getCoors();for(Coorc:coors)…{intcx=c.getX();intcy=c.getY();g.setColor(Color.black);if(c.equals(coor))…{g.setColor(Color.yellow);}g.drawLine(x,y+15,cx,cy-15);}}}}第三个是Draw.java,主控制组件,只需要在Checker中调用该类,传以适当参数,就可以了。packageat.ac.tuwien.infosys.;importat.ac.tuwien.infosys.;importat.ac.tuwien.infosys.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.util.*;/***//****@authorAdministrator*/publicclassDraw…{//声明框架privateJFrameframe=newJFrame(ControlFlowGraph);//声明书签面板privateDrawPaneldraw;privateCfgcfg;privateMapCfgNode,Coormap;privatejava.util.ListCfgNodecfgList;privatejava.util.ListCoorcoorList;privateintstartX=50;privateintstartY=30;/***//**CreatesanewinstanceofTabbedJFrame*/publicDraw(Cfgcfg)…{//this.map=newTreeMapCfgNode,Coor();this.cfgList=newLinkedListCfgNode();this.coorList=newLinkedListCoor();this.cfg=cfg;}publicvoidshow()…{frame.add(newJScrollPane(newDrawPanel(this.cfgList,this.coorList)),BorderLayout.CENTER);frame.setSize(1000,1000);frame.setLocation(50,50);frame.setVisible(true);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}/***//***将Cfg转换为cfgList和coorList.*/publicvoidconvert()…{CfgNodenode=this.cfg.getHead();intsize=this.cfg.size();Coorcoor=newCoor(startX,startY);this.cfgList.add(node);this.coorList.add(coor);System.out.println(size);java.util.ListCfgNodenoded=newLinkedListCfgNode();for(inti=0;isize;i++)…{intn=i;if(noded.contains(node))…{n=-1;for(CfgNodecfgNode:this.cfgList)…{n++;if(noded.contains(cfgNode))…{continue;}node=cfgNode;break;}}noded.add(node);//为了上边的if判断好做,故在此向noded中添加java.util.ListCfgNodelist=node.getSuccessors();intlen=list.size();if(len==0)…{continue;}intk=0;coor=this.coorList.get(this.cfgList.indexOf(node));startY=coor.getY()+60;for(CfgNodecfgNode:list)…{startX=coor.getX()+k*250;k++;if(this.cfgList.contains(cfgNode))…{Coorc=(Coor)this.coorList.get(this.cfgList.indexOf(cfgNode));if(!coor.contains(c))…{coor.addCoor(c);}continue;}coor.addCoor(newCoor(startX,startY));this.cfgList.add(cfgNode);this.coorList.add(newCoor(startX,startY));}node=list.get(0);//这里取到的CfgNode可能已经分析过了,通过上边的if判断可以从cfgList中另外取一个。}}publicvoidsetStartX(intx)…{this.startX=x;}publicvoidsetStartY(inty)…{this.startY=y;}publicintgetStartX()…{returnthis.startX;}publicintgetStartY()…{returnthis.startY;}publicvoiddump()…{System.out.println(——————);for(inti=0;ithis.cfgList.size();i++)…{CfgNodecfgNode=this.cfgList.get(i);Coorcoor=this.coorList.get(i);System.out.println(cfgNode.toString()+/**//*+cfgNode.toString()*/++coor.getX()++coor.getY()++coor.getCoors().size());}System.out.println(——————);}publicvoiddumpMap()…{java.util.ListCfgNodelist=this.cfg.dfPreOrder();System.out.println(******************);for(CfgNodenode:list)…{System.out.println(+node.toString()++node.getSuccessors().size());}System.out.println(******************);}publicstaticvoidmain(String[]args)…{//newDraw();}}可能这个项目还会做很久,中间会不会有些心得继续放到这个懒得管的空间中来呢,期待着。<

澳门新葡萄京官网首页 1

java 坦克大战 子弹击中敌方坦克 子弹消失 坦克不会消失
import java.util.Vector;
public class MyTank {
int x=0;
int y=0;
int direction=0;
int sudu=2;
public MyTank(){
}
public int getX() {
return x;
}
public void setX {
this.x = x;
}
public int getY() {
return y;
}
public void setY {
this.y = y;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public int getSudu() {
return sudu;
}
public void setSudu {
this.sudu = sudu;
}
public MyTank(int x,int y,int direction,int sudu){
this.x=x;
this.y=y;
this.direction=direction;
this.sudu=sudu;
}
public MyTank(int x,int y,int direction){
this.x=x;
this.y=y;
this.direction=direction;
}
public MyTank(int x,int y){
this.x=x;
this.y=y;
}

就是图片这样,滑动又是有分数变化的。代码:packagecom.example.administrator.game2048;importandroid.app.AlertDialog;importandroid.content.Context;importandroid.content.DialogInterface;importandroid.graphics.Point;importandroid.util.AttributeSet;importandroid.view.MotionEvent;importandroid.view.View;importandroid.widget.GridLayout;importjava.util.ArrayList;importjava.util.List;publicclassGameViewextendsGridLayout{publicGameView(Contextcontext,AttributeSetattrs,intdefStyle){super(context,attrs,defStyle);initGameView();}publicGameView(Contextcontext,AttributeSetattrs){super(context,attrs);initGameView();}publicGameView(Contextcontext){super(context);initGameView();}//游戏初始化方法privatevoidinitGameView(){setColumnCount(4);//将面板设置成4列setBackgroundColor(0xffbbada0);System.out.println(“initGameView”);setOnTouchListener(newView.OnTouchListener(){/**startX:手机刚开始在屏幕上的X坐标*startY:手机刚开始在屏幕上的Y坐标*offsetX,offsetY,分别是手指在屏幕上的X,Y上的偏移量*/privatefloatstartX,startY,offsetX,offsetY;@OverridepublicbooleanonTouch(Viewv,MotionEventevent){switch(event.getAction()){caseMotionEvent.ACTION_DOWN:startX=event.getX();startY=event.getY();break;caseMotionEvent.ACTION_UP:offsetX=event.getX()-startX;offsetY=event.getY()-startY;if(Math.abs(offsetX)Math.abs(offsetY)){if(offsetX-5){swipeLeft();System.out.println(“Left”);}elseif(offsetX5){swipeRight();System.out.println(“Right”);}}else{if(offsetY-5){swipeUp();System.out.println(“Up”);}elseif(offsetY5){swipeDown();System.out.println(“Down”);}}break;}returntrue;}});}//当布局的尺寸发生变化时,会执行该方法protectedvoidonSizeChanged(intw,inth,intoldw,intoldh){super.onSizeChanged(w,h,oldw,oldh);intcardWidth=(Math.min(w,h)-10)/4;addCards(cardWidth,cardWidth);startGame();}//添加卡片的方法privatevoidaddCards(intcardWidth,intcardHeight){Cardc;//遍历每一张卡片for(inty=0;y4;y++){for(intx=0;x4;x++){c=newCard(getContext());c.setNum(0);addView(c,cardWidth,cardHeight);cardsMap[x][y]=c;}}}//开始游戏的方法publicvoidstartGame(){MainActivity.getMainActivity().clearScore();for(inty=0;y4;y++){for(intx=0;x4;x++){cardsMap[x][y].setNum(0);emptyPoint.add(newPoint(x,y));}}addRandomNum();addRandomNum();}//添加随机数privatevoidaddRandomNum(){emptyPoint.clear();for(inty=0;y4;y++){for(intx=0;x4;x++){if(cardsMap[x][y].getNum()=0){emptyPoint.add(newPoint(x,y));}}}Pointp=emptyPoint.remove((int)(Math.random()*emptyPoint.size()));cardsMap[p.x][p.y].setNum(Math.random()0.1?2:4);}//向左滑动publicvoidswipeLeft(){booleanmeger=false;for(inty=0;y4;y++){for(intx=0;x4;x++){for(intx1=x+1;x14;x1++){if(cardsMap[x1][y].getNum()0){if(cardsMap[x][y].getNum()=0){/**将下标为所在位置的卡片上的数字*设置为,坐标为(x1,y)所在位置的卡片上的值;*第二步,将坐标所在位置的卡片上的数字*设置为0**/cardsMap[x][y].setNum(cardsMap[x1][y].getNum());cardsMap[x1][y].setNum(0);x–;meger=true;break;}elseif(cardsMap[x][y].equals(cardsMap[x1][y])){cardsMap[x][y].setNum(cardsMap[x][y].getNum()*2);cardsMap[x1][y].setNum(0);MainActivity.getMainActivity().addScore(cardsMap[x][y].getNum());meger=true;}break;}}}}if(meger){addRandomNum();checkComplete();}}//向右滑动publicvoidswipeRight(){booleanmeger=false;for(inty=0;y4;y++){for(intx=3;x=0;x–){for(intx1=x-1;x1=0;x1–){if(cardsMap[x1][y].getNum()0){if(cardsMap[x][y].getNum()=0){/**将下标为所在位置的卡片上的数字*设置为,坐标为(x1,y)所在位置的卡片上的值;*第二步,将坐标所在位置的卡片上的数字*设置为0**/cardsMap[x][y].setNum(cardsMap[x1][y].getNum());cardsMap[x1][y].setNum(0);x++;meger=true;break;}elseif(cardsMap[x][y].equals(cardsMap[x1][y])){cardsMap[x][y].setNum(cardsMap[x][y].getNum()*2);cardsMap[x1][y].setNum(0);MainActivity.getMainActivity().addScore(cardsMap[x][y].getNum());meger=true;}break;}}}}if(meger){addRandomNum();checkComplete();}}//向上滑动publicvoidswipeUp(){booleanmeger=false;for(intx=0;x4;x++){for(inty=0;y4;y++){for(inty1=y+1;y14;y1++){if(cardsMap[x][y1].getNum()0){if(cardsMap[x][y].getNum()=0){/**将下标为所在位置的卡片上的数字*设置为,坐标为(x1,y)所在位置的卡片上的值;*第二步,将坐标所在位置的卡片上的数字*设置为0**/cardsMap[x][y].setNum(cardsMap[x][y1].getNum());cardsMap[x][y1].setNum(0);y–;meger=true;break;}elseif(cardsMap[x][y].equals(cardsMap[x][y1])){cardsMap[x][y].setNum(cardsMap[x][y].getNum()*2);cardsMap[x][y1].setNum(0);MainActivity.getMainActivity().addScore(cardsMap[x][y].getNum());meger=true;}break;}}}}if(meger){addRandomNum();checkComplete();}}//向下滑动publicvoidswipeDown(){booleanmeger=false;for(intx=0;x4;x++){for(inty=3;y=0;y–){for(inty1=y-1;y1=0;y1–){if(cardsMap[x][y1].getNum()0){if(cardsMap[x][y].getNum()=0){/**将下标为所在位置的卡片上的数字*设置为,坐标为(x1,y)所在位置的卡片上的值;*第二步,将坐标所在位置的卡片上的数字*设置为0**/cardsMap[x][y].setNum(cardsMap[x][y1].getNum());cardsMap[x][y1].setNum(0);y++;meger=true;break;}elseif(cardsMap[x][y].equals(cardsMap[x][y1])){cardsMap[x][y].setNum(cardsMap[x][y].getNum()*2);cardsMap[x][y1].setNum(0);MainActivity.getMainActivity().addScore(cardsMap[x][y].getNum());meger=true;}break;

public void shang(){
y-=sudu;
this.setY;
}

public void xia(){
y+=sudu;
this.setY;
}
public void zuo(){
x-=sudu;
this.setX;
}
public void you(){
x+=sudu;
this.setX;
}

Zd zd=new Zd(this.getX(),this.getY(),this.direction);
Vector zds=new Vector();
//判断发射方向
public void fs(){
switch(this.direction){
case 0:
zd=new Zd(x+8,y-5,this.direction);
zds.add;
break;
case 1:
zd=new Zd(x+8,y+28,this.direction);
zds.add;
break;
case 2:
zd=new Zd(x-5,y+8,this.direction);
zds.add;
break;
case 3:
zd=new Zd(x+28,y+8,this.direction);
zds.add;
break;
}
Thread t=new Thread;
t.start();
}
}
//子弹类
class Zd implements Runnable{
int x=0;
int y=0;
int direction=0;
int sudu=8;
boolean shengming=true;
public Zd(int x,int y){
this.x=x;
this.y=y;
}
public Zd(int x,int y,int direction){
this.x=x;
this.y=y;
this.direction=direction;
}
public void run(){
while{
try {
Thread.sleep;
} catch (Exception e) {
}
switch(direction){
case 0:
y-=sudu;
break;
case 1:
y+=sudu;
break;
case 2:
x-=sudu;
break;
case 3:
x+=sudu;
break;
}
//判断子弹出界面
if(x500||y400){
this.shengming=false;
}
}
}
}
//敌方坦克类
public class EnemyTank {
int x=0;
int y=0;
int direction=0;
int sudu=5;
boolean shengming=true;
public int getX() {
return x;
}
public void setX {
this.x = x;
}
public int getY() {
return y;
}
public void setY {
this.y = y;
}
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public int getSudu() {
return sudu;
}
public void setSudu {
this.sudu = sudu;
}

public EnemyTank(int x,int y,int direction){
this.x=x;
this.y=y;
this.direction=direction;
}

public EnemyTank(int x,int y){
this.x=x;
this.y=y;
}
}
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Tank1 {
public static void main(String[] args) {
MianBan mb=new MianBan();
}
}
class MianBan extends JFrame{
HuaBi hb=null;
public MianBan(){
this.setSize;
this.setLocation;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
hb=new HuaBi();
this.add;
this.addKeyListener;
this.setVisible;
}
}
class HuaBi extends JPanel implements KeyListener ,Runnable{
MyTank mt=null;
public HuaBi(){
mt=new MyTank;
}
public void paint(Graphics g){
super.paint;
g.fillRect(0, 0, 500, 400); //背景

//我放坦克this.huaTank, mt.getY(), g, 1, this.mt.getDirection;//子弹for(int i=0;i<mt.zds.size{ Zd zd=mt.zds.get; if(mt.zd!=null&&mt.zd.shengming==true){ g.setColor(Color.white); g.fill3DRect(zd.x,zd.y, 3, 3, false); } if(zd.shengming==false){ mt.zds.remove; }} //敌方坦克Vector<EnemyTank> dtk=new Vector<EnemyTank>();EnemyTank et=null;int num=3;for(int i=0;i<num;i++){ et=new EnemyTank*226+6,10,1); dtk.add;}//绘制敌方坦克for(int i=0;i<dtk.size{ et=dtk.get; if(et!=null&&et.shengming==true){ this.huaTank, et.getY(), g, 0, 1); } if(et.shengming==false){ dtk.remove; }}//比较子弹和坦克坐标for(int i=0;i<mt.zds.size{ for(int j=0;j<dtk.size{ if(mt.zds.get.shengming==true){ if(dtk.get.shengming==true){ this.jzdf(mt.zds.get, dtk.get; } } }}this.repaint();

}

//判断子弹是否击中敌方坦克
public void jzdf(Zd zd,EnemyTank et){
if(zd.x>et.x&&zd.xet.y&&zd.y<et.y+30){
zd.shengming=false;
et.shengming=false;
}
}

//fx为坦克方向
public void huaTank(int x,int y,Graphics g,int color,int fx){
switch{
case 0:
g.setColor(Color.green);
break;
case 1:
g.setColor(Color.yellow);
break;
}
//坦克方向
switch{
case 0: //上
g.fill3DRect(x, y, 5, 26, false);
g.fill3DRect(x+15, y, 5, 26, false);
g.fill3DRect(x+4, y+4, 16, 20, false);
g.fillOval(x+4, y+8, 10, 10);
g.drawLine(x+9, y+15, x+9, y-4);
break;
case 1:
//下
g.fill3DRect(x, y, 5, 26, false);
g.fill3DRect(x+15, y, 5, 26, false);
g.fill3DRect(x+4, y+1, 16, 20, false);
g.fillOval(x+4, y+5, 10, 10);
g.drawLine(x+9, y+15, x+9, y+27);
break;
case 2:
//左
g.fill3DRect(x, y, 26, 5, false);
g.fill3DRect(x, y+15, 26, 5, false);
g.fill3DRect(x+4, y+4, 20, 16, false);
g.fillOval(x+10, y+5, 10, 10);
g.drawLine(x+15, y+9, x-4, y+9);
break;
case 3:
//右
g.fill3DRect(x, y, 26, 5, false);
g.fill3DRect(x, y+15, 26, 5, false);
g.fill3DRect(x+1, y+4, 20, 16, false);
g.fillOval(x+5, y+5, 10, 10);
g.drawLine(x+15, y+9, x+27, y+9);
break;
}
this.repaint();
}
public void keyTyped(KeyEvent e) {

}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_W){
// System.out.println;
this.mt.setDirection;
this.mt.shang();
}else if(e.getKeyCode()==KeyEvent.VK_A){
// System.out.println;
this.mt.zuo();
this.mt.setDirection;
}else if(e.getKeyCode()==KeyEvent.VK_D){
// System.out.println;
this.mt.you();
this.mt.setDirection;
}else if(e.getKeyCode()==KeyEvent.VK_S){
// System.out.println;
this.mt.setDirection;
this.mt.xia();
}
if(e.getKeyCode()==KeyEvent.VK_J){
if(mt.zds.size{
this.mt.fs();
}
}
this.repaint();
}
public void keyReleased(KeyEvent e) {
}

@Override
public void run() {

}
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注