@@ -35,9 +35,10 @@ public function index(Request $request)
3535 $ where = $ cms ? array_merge ($ where , ['info.cms ' => $ cms ]) : $ where ;
3636 $ where = $ server ? array_merge ($ where , ['info.server ' => $ server ]) : $ where ;
3737
38-
38+ $ where1 = [];
3939 if ($ this ->auth_group_id != 5 && !in_array ($ this ->userId , config ('app.ADMINISTRATOR ' ))) {
4040 $ where = array_merge ($ where , ['user_id ' => $ this ->userId ]);
41+ $ where1 [] = ['user_id ' , '= ' , $ this ->userId ];
4142 }
4243
4344 $ data ['list ' ] = Db::table ('app ' )->LeftJoin ('app_info info ' , 'app.id = info.app_id ' )->where ($ where )->limit ($ pageSize )->page ($ page )->select ()->toArray ();
@@ -63,6 +64,20 @@ public function index(Request $request)
6364 } else {
6465 $ v ['status ' ] = '禁用 ' ;
6566 }
67+
68+ // 数据统计
69+ $ v ['oneforall_num ' ] = Db::table ('one_for_all ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
70+ $ v ['dirmap_num ' ] = Db::table ('app_dirmap ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
71+ $ v ['sqlmap_num ' ] = Db::table ('urls_sqlmap ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
72+ $ v ['vulmap_num ' ] = Db::table ('app_vulmap ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
73+ //$data['dismap_num'] = Db::table('app_dismap')->where($where1)->count('id');
74+ $ v ['urls_num ' ] = Db::table ('urls ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
75+ $ v ['xray_num ' ] = Db::table ('xray ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
76+ //$data['nuclei_num'] = Db::table('app_nuclei')->where($where1)->count('id');
77+ $ v ['crawlergo_num ' ] = Db::table ('app_crawlergo ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
78+ $ v ['awvs_num ' ] = Db::table ('awvs_vuln ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
79+ $ v ['namp_num ' ] = Db::table ('host_port ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
80+ $ v ['host_num ' ] = Db::table ('host ' )->where ('app_id ' , $ v ['id ' ])->where ($ where1 )->count ('id ' );
6681 }
6782 $ data ['pageSize ' ] = $ pageSize ;
6883 $ data ['count ' ] = Db::table ('app ' )->Join ('app_info info ' , 'app.id = info.app_id ' )->where ($ where )->count ();
@@ -152,9 +167,13 @@ public function del(Request $request)
152167 $ map [] = ['user_id ' , '= ' , $ this ->userId ];
153168 }
154169 $ data ['info ' ] = Db::name ('app ' )->where (['id ' => $ id ])->find ();
155- $ urlInfo = parse_url ($ data ['info ' ]['url ' ]);
156- $ ip = gethostbyname ($ urlInfo ['host ' ]);
157-
170+ if (!empty ($ data )) {
171+ $ urlInfo = parse_url ($ data ['info ' ]['url ' ]);
172+ $ ip = gethostbyname ($ urlInfo ['host ' ] ?? '127.0.0.1 ' );
173+ Db::table ('app_info ' )->where (['app_id ' => $ id ])->delete ();
174+ Db::table ('host ' )->where (['host ' => $ ip ])->delete ();
175+ Db::table ('host_port ' )->where (['host ' => $ ip ])->delete ();
176+ }
158177 Db::table ('app_crawlergo ' )->where (['app_id ' => $ id ])->delete ();
159178 Db::table ('app_dirmap ' )->where (['app_id ' => $ id ])->delete ();
160179 Db::table ('app_nuclei ' )->where (['app_id ' => $ id ])->delete ();
@@ -164,9 +183,7 @@ public function del(Request $request)
164183 Db::table ('app_whatweb_poc ' )->where (['app_id ' => $ id ])->delete ();
165184 Db::table ('app_xray_agent_port ' )->where (['app_id ' => $ id ])->delete ();
166185 Db::table ('awvs_app ' )->where (['app_id ' => $ id ])->delete ();
167- Db::table ('host ' )->where (['host ' => $ ip ])->delete ();
168186 Db::table ('host_hydra_scan_details ' )->where (['app_id ' => $ id ])->delete ();
169- Db::table ('host_port ' )->where (['host ' => $ ip ])->delete ();
170187 Db::table ('one_for_all ' )->where (['app_id ' => $ id ])->delete ();
171188 Db::table ('plugin_scan_log ' )->where (['app_id ' => $ id ])->delete ();
172189 Db::table ('urls ' )->where (['app_id ' => $ id ])->delete ();
@@ -245,6 +262,7 @@ public function details(Request $request)
245262 $ data ['nuclei ' ] = Db::table ('app_nuclei ' )->where ($ where )->order ("app_id " , 'desc ' )->limit (0 , 15 )->select ()->toArray ();
246263 $ data ['crawlergo ' ] = Db::table ('app_crawlergo ' )->where ($ where )->order ("app_id " , 'desc ' )->limit (0 , 15 )->select ()->toArray ();
247264 $ data ['awvs ' ] = Db::table ('awvs_vuln ' )->where ($ where )->order ("app_id " , 'desc ' )->limit (0 , 15 )->select ()->toArray ();
265+ $ data ['pluginScanLog ' ] = Db::table ('plugin_scan_log ' )->where ($ where )->where (['log_type ' => 1 ])->order ("app_id " , 'desc ' )->limit (0 , 15 )->select ()->toArray ();
248266 //获取此域名对应主机的端口信息
249267 $ urlInfo = parse_url ($ data ['info ' ]['url ' ]);
250268 $ ip = gethostbyname ($ urlInfo ['host ' ]);
@@ -273,23 +291,29 @@ public function qingkong(Request $request)
273291 'crawlergo_scan_time ' => '2000-01-01 00:00:00 ' ,
274292 'vulmap_scan_time ' => '2000-01-01 00:00:00 ' ,
275293 );
276- $ data ['info ' ] = Db::name ('app ' )->where (['id ' => $ id ])->find ();
277- $ urlInfo = parse_url ($ data ['info ' ]['url ' ]);
278- $ ip = gethostbyname ($ urlInfo ['host ' ]);
279-
294+ $ where [] = ['id ' , '= ' , $ id ];
295+ if ($ this ->auth_group_id != 5 && !in_array ($ this ->userId , config ('app.ADMINISTRATOR ' ))) {
296+ $ where [] = ['user_id ' , '= ' , $ this ->userId ];
297+ }
298+ $ data ['info ' ] = Db::name ('app ' )->where ($ where )->find ();
299+ if (!$ data ['info ' ]) {
300+ $ this ->error ('黑盒数据不存在 ' );
301+ }
280302 Db::table ('app ' )->where (['id ' => $ id ])->save ($ array );
303+ Db::table ('app_info ' )->where (['app_id ' => $ id ])->delete ();
281304 Db::table ('app_crawlergo ' )->where (['app_id ' => $ id ])->delete ();
282305 Db::table ('app_dirmap ' )->where (['app_id ' => $ id ])->delete ();
306+ Db::table ('app_dismap ' )->where (['app_id ' => $ id ])->delete ();
283307 Db::table ('app_nuclei ' )->where (['app_id ' => $ id ])->delete ();
284308 Db::table ('app_vulmap ' )->where (['app_id ' => $ id ])->delete ();
285309 Db::table ('app_wafw00f ' )->where (['app_id ' => $ id ])->delete ();
286310 Db::table ('app_whatweb ' )->where (['app_id ' => $ id ])->delete ();
287311 Db::table ('app_whatweb_poc ' )->where (['app_id ' => $ id ])->delete ();
288312 Db::table ('app_xray_agent_port ' )->where (['app_id ' => $ id ])->delete ();
289313 Db::table ('awvs_app ' )->where (['app_id ' => $ id ])->delete ();
290- Db::table ('host ' )->where (['host ' => $ ip ])->delete ();
314+ Db::table ('host ' )->where (['app_id ' => $ id ])->delete ();
291315 Db::table ('host_hydra_scan_details ' )->where (['app_id ' => $ id ])->delete ();
292- Db::table ('host_port ' )->where (['host ' => $ ip ])->delete ();
316+ Db::table ('host_port ' )->where (['app_id ' => $ id ])->delete ();
293317 Db::table ('one_for_all ' )->where (['app_id ' => $ id ])->delete ();
294318 Db::table ('plugin_scan_log ' )->where (['app_id ' => $ id ])->delete ();
295319 Db::table ('urls ' )->where (['app_id ' => $ id ])->delete ();
@@ -301,6 +325,119 @@ public function qingkong(Request $request)
301325 }
302326
303327
328+ public function rescan (Request $ request )
329+ {
330+ $ id = $ request ->param ('id ' );
331+ $ where [] = ['id ' , '= ' , $ id ];
332+ if ($ this ->auth_group_id != 5 && !in_array ($ this ->userId , config ('app.ADMINISTRATOR ' ))) {
333+ $ where [] = ['user_id ' , '= ' , $ this ->userId ];
334+ }
335+ $ info = Db::name ('app ' )->where ($ where )->find ();
336+ if (!$ info ) {
337+ $ this ->error ('黑盒数据不存在 ' );
338+ }
339+ $ tools_name = $ request ->param ('tools_name ' , '' );
340+
341+ switch ($ tools_name ) {
342+ case 'rad ' :
343+ $ data = [
344+ 'crawler_time ' => '2000-01-01 00:00:00 '
345+ ];
346+ Db::table ('urls ' )->where (['app_id ' => $ id ])->delete ();
347+ Db::table ('urls_sqlmap ' )->where (['app_id ' => $ id ])->delete ();
348+ break ;
349+ case 'crawlergoScan ' :
350+ $ data = [
351+ 'crawlergo_scan_time ' => '2000-01-01 00:00:00 ' ,
352+ ];
353+ Db::table ('app_crawlergo ' )->where (['app_id ' => $ id ])->delete ();
354+ break ;
355+ case 'awvsScan ' :
356+ $ data = [
357+ 'awvs_scan_time ' => '2000-01-01 00:00:00 ' ,
358+ ];
359+ Db::table ('awvs_app ' )->where (['app_id ' => $ id ])->delete ();
360+ break ;
361+ case 'nucleiScan ' :
362+ $ data = [
363+ 'nuclei_scan_time ' => '2000-01-01 00:00:00 ' ,
364+ ];
365+ Db::table ('app_nuclei ' )->where (['app_id ' => $ id ])->delete ();
366+ break ;
367+ case 'xray ' :
368+ $ data = [
369+ 'xray_scan_time ' => '2000-01-01 00:00:00 ' ,
370+ ];
371+ Db::table ('xray ' )->where (['app_id ' => $ id ])->delete ();
372+ break ;
373+ case 'getBaseInfo ' :
374+ $ data = [
375+ 'screenshot_time ' => '2000-01-01 00:00:00 ' ,
376+ ];
377+ Db::table ('app_info ' )->where (['app_id ' => $ id ])->delete ();
378+ break ;
379+ case 'whatweb ' :
380+ $ data = [
381+ 'whatweb_scan_time ' => '2000-01-01 00:00:00 ' ,
382+ ];
383+ Db::table ('app_whatweb ' )->where (['app_id ' => $ id ])->delete ();
384+ Db::table ('app_whatweb_poc ' )->where (['app_id ' => $ id ])->delete ();
385+ break ;
386+ case 'sqlmapScan ' :
387+ Db::table ('urls ' )->where (['app_id ' => $ id ])->update (['sqlmap_scan_time ' => '2000-01-01 00:00:00 ' ]);
388+ Db::table ('urls_sqlmap ' )->where (['app_id ' => $ id ])->delete ();
389+ break ;
390+ case 'subdomainScan ' :
391+ $ data = [
392+ 'subdomain_scan_time ' => '2000-01-01 00:00:00 ' ,
393+ ];
394+ Db::table ('one_for_all ' )->where (['app_id ' => $ id ])->delete ();
395+ break ;
396+ case 'sshScan ' :
397+ Db::table ('host ' )->where (['app_id ' => $ id ])->update (['hydra_scan_time ' => '2000-01-01 00:00:00 ' ]);
398+ Db::table ('host_hydra_scan_details ' )->where (['app_id ' => $ id ])->delete ();
399+ break ;
400+ case 'dirmapScan ' :
401+ $ data = [
402+ 'dirmap_scan_time ' => '2000-01-01 00:00:00 ' ,
403+ ];
404+ Db::table ('app_dirmap ' )->where (['app_id ' => $ id ])->delete ();
405+ break ;
406+ case 'NmapPortScan ' :
407+ Db::table ('host_port ' )->where (['app_id ' => $ id ])->update (['service ' => null ]);
408+ break ;
409+ case 'vulmapPocTest ' :
410+ $ data = [
411+ 'vulmap_scan_time ' => '2000-01-01 00:00:00 ' ,
412+ ];
413+ Db::table ('app_vulmap ' )->where (['app_id ' => $ id ])->delete ();
414+ break ;
415+ case 'autoAddHost ' :
416+ Db::table ('host ' )->where (['app_id ' => $ id ])->delete ();
417+ Db::table ('host_port ' )->where (['app_id ' => $ id ])->delete ();
418+ Db::table ('host_hydra_scan_details ' )->where (['app_id ' => $ id ])->delete ();
419+ break ;
420+ case 'dismapScan ' :
421+ $ data = [
422+ 'dismap_scan_time ' => '2000-01-01 00:00:00 ' ,
423+ ];
424+ Db::table ('app_dismap ' )->where (['app_id ' => $ id ])->delete ();
425+ break ;
426+ case 'plugin ' :
427+ Db::table ('plugin_scan_log ' )->where (['app_id ' => $ id ])->delete ();
428+ break ;
429+ default :
430+ $ this ->error ('参数错误 ' );
431+ break ;
432+ }
433+ Db::table ('plugin_scan_log ' )->where (['app_id ' => $ id , 'scan_type ' => 0 ,'plugin_name ' =>$ tools_name ])->delete ();
434+ if (!empty ($ data )) {
435+ Db::table ('app ' )->where (['id ' => $ id ])->update ($ data );
436+ }
437+ return redirect ($ _SERVER ['HTTP_REFERER ' ] ?? '/ ' );
438+ }
439+
440+
304441 public function start_agent (Request $ request )
305442 {
306443 $ id = $ request ->param ('id ' , '' , 'intval ' );
0 commit comments