PHP静态分析与跨站脚本检测

近些日子在看PHP静态分析与跨站脚本检查评定的事物,用的是高雄高校三个大学子生做出来的Pixy,那个事物是开源的,并且也作了少数年了,功用稳步进步。未来以此3.0.3版本里边有2二十四个程序,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(State of Qatar;this.x=x;this.y=y;}publicintgetX(卡塔尔(قطر‎…{returnthis.x;}publicintgetY(卡塔尔国…{returnthis.y;}publicListCoorgetCoors(卡塔尔…{returnthis.coors;}publicvoidaddCoor(Coorcoor卡塔尔…{this.coors.add(coorState of Qatar;}publicbooleanequals(Coorcoor卡塔尔国…{if(coor.getX(State of Qatar==this.xcoor.getY(卡塔尔国==y卡塔尔…{returntrue;}returnfalse;}publicbooleancontains(Coorc卡塔尔(قطر‎…{for(Coorcoor:this.coors卡塔尔(قطر‎…{if(coor.getX(卡塔尔(قطر‎==c.getX(卡塔尔国coor.getY(卡塔尔(قطر‎==c.getY(卡塔尔国State of Qatar…{returntrue;}}returnfalse;}}第3个是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.ListCoorcoorListState of Qatar…{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(卡塔尔State of Qatar,x,y+10卡塔尔国;java.util.ListCoorcoors=coor.getCoors(State of Qatar;for(Coorc:coors卡塔尔国…{intcx=c.getX(State of Qatar;intcy=c.getY(卡塔尔国;g.setColor(Color.black卡塔尔国;if(c.equals(coor卡塔尔(قطر‎卡塔尔…{g.setColor(Color.yellowState of Qatar;}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(State of Qatar;for(inti=0;isize;i++卡塔尔(قطر‎…{intn=i;if(noded.contains(nodeState of Qatar卡塔尔国…{n=-1;for(CfgNodecfgNode:this.cfgListState of Qatar…{n++;if(noded.contains(cfgNode卡塔尔国卡塔尔国…{continue;}node=cfgNode;break;}}noded.add(node卡塔尔(قطر‎;//为了上边包车型客车if剖断好做,故在这里向noded中加多java.util.ListCfgNodelist=node.getSuccessors(卡塔尔;intlen=list.size(卡塔尔;if(len==0State of Qatar…{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卡塔尔国State of Qatar;}node=list.get(0卡塔尔(قطر‎;//这里取到的CfgNode大概早就解析过了,通过下面的if决断能够从cfgList中此外取八个。}}publicvoidsetStartX(intxState of Qatar…{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(State of Qatar;}}大概这些项目还有大概会做比较久,中间会不会有个别心得继续放到那几个懒得管的空中中来呢,期瞅着。<

importjava.awt.*;importjava.net.*;importjava.io.*;importjava.util.*;importjava.awt.event.*;importjava.awt.geom.*;classOmokBoardextendsCanvas{publicstaticfinalintBLACK=1,WHITE=-1;//定义黑白颜色伊始值privateint[][]map;//定义二维数组用于记录地图坐标privateintsize,cell;//定义大小和表格privateStringinfo=”游戏终止”;//定于提醒新闻privateintcolor=BLACK;//定义颜色最初值privatebooleanenable=false;//定义布尔类型值privatebooleanrunning=false;//定义布尔类型值privatePrintWriterwriter;privateGraphicsgboard,gbuff;//定义图形抽象类privateImagebuff;OmokBoard(ints,intcState of Qatar{this.size=s;this.cell=c;map=newint[size+2][];//实例化地图for(inti=0;imap.length;i++卡塔尔(قطر‎//for循环生成地图map[i]=newint[size+2];//设置地图成分setBackground(newColor(200,200,100State of Qatar卡塔尔;//设置背景颜色及大小setSize(size*(cell+1)+size,size*(cell+1卡塔尔+size卡塔尔;//设置大小addMouseListener(newMouseAdapter(卡塔尔{//鼠标监听事件publicvoidmousePressed(MouseEventme卡塔尔国{//鼠标经过事件if(!enable卡塔尔国return;//推断enable的值intx=(int卡塔尔国Math.round(me.getX(State of Qatar/(double卡塔尔cell卡塔尔(قطر‎;//四舍五入获得值inty=(int卡塔尔国Math.round(me.getY(卡塔尔国/(double卡塔尔(قطر‎cellState of Qatar;if(x==0||y==0||x==size+1||y==size+1卡塔尔return;//剖断并回到if(map[x][y]==BLACK||map[x][y]==WHITE卡塔尔国return;//判别并再次来到writer.println(“[STONE]”+x+””+y卡塔尔;//打字与印刷出石子map[x][y]=color;//设置钦定地点的颜色if(check(newPoint(x,yState of Qatar,color卡塔尔(قطر‎卡塔尔{info=”获胜.”;//设置新闻writer.println(“[WIN]”卡塔尔(قطر‎;//打印新闻}elseinfo=”等待对方落子.”;//设置新闻repaint(卡塔尔国;enable=false;//设置enable的值}}卡塔尔国;}publicbooleanisRunning(卡塔尔国{returnrunning;}publicvoidstartGame(StringcolState of Qatar{running=true;if(col.equals(“BLACK”State of Qatar卡塔尔(قطر‎{//推断颜色enable=true;color=BLACK;info=”最初游戏…请落子.”;}else{enable=false;color=WHITE;info=”开端游戏…请等待.”;}}publicvoidstopGame(卡塔尔国{reset(卡塔尔;//重值私下认可为先导值writer.println(“[STOPGAME]”);enable=false;running=false;}publicvoidputOpponent(intx,inty){map[x][y]=-color;info=”对手已落子…请落子.”;repaint(State of Qatar;}publicvoidsetEnable(booleanenable卡塔尔(قطر‎{this.enable=enable;}publicvoidsetWriter(PrintWriterwriterState of Qatar{this.writer=writer;}publicvoidupdate(Graphicsg卡塔尔(قطر‎{paint(g卡塔尔;}publicvoidpaint(Graphicsg卡塔尔(قطر‎{if(gbuff==null卡塔尔{buff=createImage(getWidth(卡塔尔,getHeight(卡塔尔卡塔尔;gbuff=buff.getGraphics(卡塔尔;}drawBoard(g卡塔尔国;}publicvoidreset(State of Qatar{for(inti=0;imap.length;i++卡塔尔for(intj=0;jmap[i].length;j++)map[i][j]=0;info=”游戏终止”;repaint(卡塔尔国;}privatevoiddrawLine(卡塔尔{gbuff.setColor(Color.black卡塔尔国;for(inti=1;i=size;i++卡塔尔{gbuff.drawLine(cell,i*cell,cell*size,i*cell);gbuff.drawLine(i*cell,cell,i*cell,cell*size);}}privatevoiddrawBlack(intx,inty){Graphics2Dgbuff=(Graphics2D)this.gbuff;gbuff.setColor(Color.black);gbuff.fillOval(x*cell-cell/2,y*cell-cell/2,cell,cell);gbuff.setColor(Color.white);gbuff.drawOval(x*cell-cell/2,y*cell-cell/2,cell,cell);}privatevoiddrawWhite(intx,inty){gbuff.setColor(Color.white);gbuff.fillOval(x*cell-cell/2,y*cell-cell/2,cell,cell);gbuff.setColor(Color.black);gbuff.drawOval(x*cell-cell/2,y*cell-cell/2,cell,cell);}privatevoiddrawStones(){for(intx=1;x=size;x++)for(inty=1;y=size;y++){if(map[x][y]==BLACK)drawBlack(x,y);elseif(map[x][y]==WHITE)drawWhite(x,y);}}synchronizedprivatevoiddrawBoard(Graphicsg){gbuff.clearRect(0,0,getWidth(),getHeight());drawLine();drawStones();gbuff.setColor(Color.red);gbuff.drawString(info,20,15);g.drawImage(buff,0,0,this);}privatebooleancheck(Pointp,intcol){if(count(p,1,0,col)+count(p,-1,0,col)==4)returntrue;if(count(p,0,1,col)+count(p,0,-1,col)==4)returntrue;if(count(p,-1,-1,col)+count(p,1,1,col)==4)returntrue;if(count(p,1,-1,col)+count(p,-1,1,col)==4)returntrue;returnfalse;}privateintcount(Pointp,intdx,intdy,intcol){inti=0;for(;map[p.x+(i+1)*dx][p.y+(i+1)*dy]==col;i++State of Qatar;returni;}}publicclassOmokClientextendsFrameimplementsRunnable,ActionListener{privateTextAreamsgView=newTextArea(“”,1,1,1State of Qatar;privateTextFieldsendBox=newTextField(“”卡塔尔(قطر‎;privateTextFieldnameBox=newTextField(卡塔尔国;privateTextFieldroomBox=newTextField(“0″卡塔尔;privateLabelpInfo=newLabel(“等待室:名”卡塔尔(قطر‎;privatejava.awt.ListpList=newjava.awt.List(卡塔尔;privateButtonstartButton=newButton(“初阶对决”卡塔尔;privateButtonstopButton=newButton(“弃权”State of Qatar;privateButtonenterButton=newButton(“登台”卡塔尔国;privateButtonexitButton=newButton(“去待机室”State of Qatar;privateLabelinfoView=newLabel(“2019电商大作业”,1卡塔尔国;privateOmokBoardboard=newOmokBoard(15,30State of Qatar;privateBufferedReaderreader;privatePrintWriterwriter;privateSocketsocket;privateintroomNumber=-1;privateStringuserName=null;publicOmokClient(Stringtitle卡塔尔国{super(title卡塔尔(قطر‎;setLayout(null卡塔尔;msgView.setEditable(false卡塔尔(قطر‎;infoView.setBounds(10,30,480,30卡塔尔国;infoView.setBackground(newColor(200,200,255State of Qatar卡塔尔国;board.setLocation(10,70卡塔尔国;add(infoView卡塔尔;add(board卡塔尔;Panelp=newPanel(卡塔尔国;p.setBackground(newColor(200,255,255卡塔尔卡塔尔(قطر‎;p.setLayout(newGridLayout(3,3卡塔尔(قطر‎卡塔尔;p.add(newLabel(“名子:”,2State of Qatar卡塔尔(قطر‎;p.add(nameBox卡塔尔(قطر‎;p.add(newLabel(“房间号:”,2卡塔尔卡塔尔;p.add(roomBox卡塔尔(قطر‎;p.add(enterButton卡塔尔国;p.add(exitButton卡塔尔(قطر‎;enterButton.setEnabled(falseState of Qatar;p.setBounds(500,30,250,70卡塔尔(قطر‎;Panelp2=newPanel(卡塔尔;p2.setBackground(newColor(255,255,100State of Qatar卡塔尔国;p2.setLayout(newBorderLayout(卡塔尔State of Qatar;Panelp2_1=newPanel();p2_1.add(startButton);p2_1.add(stopButton);p2.add(pInfo,”North”);p2.add(pList,”Center”);p2.add(p2_1,”South”);startButton.setEnabled(false);stopButton.setEnabled(false);p2.setBounds(500,110,250,180);Panelp3=newPanel();p3.setLayout(newBorderLayout());p3.add(msgView,”Center”);p3.add(sendBox,”South”);p3.setBounds(500,300,250,250);add(p);add(p2);add(p3);sendBox.addActionListener(this);enterButton.addActionListener(this);exitButton.addActionListener(this);startButton.addActionListener(this);stopButton.addActionListener(this);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEventwe){System.exit(0);}});}publicvoidactionPerformed(ActionEventae){if(ae.getSource()==sendBox){Stringmsg=sendBox.getText();if(msg.length()==0)return;if(msg.length()=30)msg=msg.substring(0,30);try{writer.println(“[MSG]”+msg卡塔尔(قطر‎;sendBox.setText(“”卡塔尔(قطر‎;}catch(ExceptionieState of Qatar{}}elseif(ae.getSource(State of Qatar==enterButton卡塔尔(قطر‎{try{if(Integer.parseInt(roomBox.getText(卡塔尔卡塔尔(قطر‎1State of Qatar{infoView.setText(“房间号错误,大于1″State of Qatar;return;}writer.println(“[ROOM]”+Integer.parseInt(room博克斯.getText(State of Qatar卡塔尔卡塔尔(قطر‎;msgView.setText(“”卡塔尔(قطر‎;}catch(ExceptionieState of Qatar{infoView.setText(“输入的事项产生错误.”卡塔尔国;}}elseif(ae.getSource(卡塔尔==exitButtonState of Qatar{try{goToWaitRoom(State of Qatar;startButton.setEnabled(false卡塔尔(قطر‎;stopButton.setEnabled(false卡塔尔国;}catch(Exceptione卡塔尔国{}}elseif(ae.getSource(卡塔尔==startButton卡塔尔(قطر‎{try{writer.println(“[START]”State of Qatar;infoView.setText(“等待对方决定.”卡塔尔;startButton.setEnabled(false卡塔尔(قطر‎;}catch(Exceptione卡塔尔国{}}elseif(ae.getSource(State of Qatar==stopButton卡塔尔国{try{writer.println(“[DROPGAME]”卡塔尔;endGame(“已弃权.”卡塔尔;}catch(Exceptione卡塔尔(قطر‎{}}}voidgoToWaitRoom(卡塔尔国{if(userName==null卡塔尔{Stringname=nameBox.getText(卡塔尔(قطر‎.trim(State of Qatar;if(name.length(卡塔尔国=2||name.length(卡塔尔10卡塔尔{infoView.setText(“房间号错误.3~10个数”);nameBox.requestFocus();return;}userName=name;writer.println(“[NAME]”+userName);nameBox.setText(userName);nameBox.setEditable(false);}msgView.setText(“”);writer.println(“[ROOM]0″卡塔尔国;infoView.setText(“已进待机室.”State of Qatar;roomBox.setText(“0″State of Qatar;enterButton.setEnabled(true卡塔尔国;exitButton.setEnabled(falseState of Qatar;}publicvoidrun(卡塔尔{Stringmsg;try{while((msg=reader.readLine(卡塔尔(قطر‎卡塔尔!=null){if(msg.startsWith(“[STONE]”)){Stringtemp=msg.substring(7);intx=Integer.parseInt(temp.substring(0,temp.indexOf(“”)));inty=Integer.parseInt(temp.substring(temp.indexOf(“”)+1));board.putOpponent(x,y);board.setEnable(true);}elseif(msg.startsWith(“[ROOM]”)){if(!msg.equals(“[ROOM]0″卡塔尔(قطر‎State of Qatar{enterButton.setEnabled(falseState of Qatar;exitButton.setEnabled(true卡塔尔;infoView.setText(msg.substring(6卡塔尔国+”号房间已被步向.”State of Qatar;}elseinfoView.setText(“已步入待机室.”State of Qatar;roomNumber=Integer.parseInt(msg.substring(6State of Qatar卡塔尔;if(board.isRunning(State of Qatar卡塔尔(قطر‎{board.stopGame(卡塔尔;}}elseif(msg.startsWith(“[FULL]”卡塔尔国卡塔尔(قطر‎{infoView.setText(“房间满员,防止入内.”卡塔尔(قطر‎;}elseif(msg.startsWith(“[PLAYERS]”)){nameList(msg.substring(9));}elseif(msg.startsWith(“[ENTER]”)){pList.add(msg.substring(7));playersInfo();msgView.append(“[“+msg.substring(7)+”]入场.n”);}elseif(msg.startsWith(“[EXIT]”)){pList.remove(msg.substring(6));playersInfo();msgView.append(“[“+msg.substring(6)+”]步入其它房间.n”);if(roomNumber!=0State of QatarendGame(“对方已离开.”State of Qatar;}elseif(msg.startsWith(“[DISCONNECT]”)){pList.remove(msg.substring(12));playersInfo();msgView.append(“[“+msg.substring(12)+”]停顿连接.n”);if(roomNumber!=0卡塔尔(قطر‎endGame(“对方离开.”卡塔尔(قطر‎;

发表评论

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