Skip to content

Commit 444f2e5

Browse files
committed
Merge branch 'test' into main
2 parents aca2f49 + 0f61248 commit 444f2e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1520
-315
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ QingScan 是一款聚合扫描器,本身不生产安全扫描功能,但会
1919
2020
## 安装教程
2121

22-
1. 需要安装docker、docker-compose 安装方法http://get.daocloud.io/
22+
1. 需要安装docker、docker-compose 安装方法 http://get.daocloud.io/
2323
2. 下载代码后,启动容器`cd QingScan/docker/latest && docker-compose up -d `
2424
2. <b>首次</b>启动需要更新容器内代码`docker exec qingscan sh -c 'cd /root/qingscan && git fetch && git reset --hard origin/main && rm code/public/install/install.lock' `
2525
3. 依次执行命令创建MySQL数据库`docker exec -it mysqlser bash`,进入数据库交互`mysql -uroot -p123` ,执行创建数据库 `CREATE DATABASE IF NOT EXISTS QingScan;`

code/app/common.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,11 @@ function curl_get($url)
762762
//执行命令
763763
$data = curl_exec($curl);
764764

765-
//如果有异常,记录到日志当中
766-
$curl_errno = curl_errno($curl);
767-
if (curl_errno($curl)) {
768-
//return 'Curl error: ' . curl_error($curl);
765+
if ($data === false) {
766+
return json_encode([
767+
'code'=>1,
768+
'msg'=>curl_error($curl)
769+
]);
769770
}
770771

771772
curl_close($curl);
@@ -1195,7 +1196,7 @@ function getScanStatus($appId, $pluginName, $scanType = 0)
11951196
$where = ['app_id' => $appId, 'plugin_name' => $pluginName, 'scan_type' => $scanType];
11961197
$result = Db::table('plugin_scan_log')->where($where)->order('log_type', 'asc')->select()->toArray();
11971198
if (empty($result)) {
1198-
return "扫描未开始,请检查插件是否开启~";
1199+
return "扫描未开始,请检查插件是否开启以及日志排队状态~";
11991200
} elseif (count($result) == 1) {
12001201
return "$pluginName 任务已在{$result[0]['create_time']}启动,请等待扫描结果~";
12011202
} elseif (count($result) == 2 && $result[1]['log_type'] == 2) {

code/app/controller/App.php

Lines changed: 149 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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');

code/app/controller/Bug.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public function awvs()
2121
if (!empty($search)) {
2222
$where[] = ['vt_name|affects_url','like',"%{$search}%"];
2323
}
24-
$pid = getParam('code_id');
24+
$app_id = getParam('app_id');
2525
$level = getParam('level'); // 等级
2626
$Category = getParam('Category'); // 分类
2727
$filename = getParam('filename'); // 文件名
2828
$check_status = getParam('check_status'); // 审核状态
29-
if (!empty($pid)) {
30-
$where[] = ['app_id','=',$pid];
29+
if (!empty($app_id)) {
30+
$where[] = ['app_id','=',$app_id];
3131
}
3232
if (!empty($level)) {
3333
$where[] = ['severity','=',$level];
@@ -42,7 +42,7 @@ public function awvs()
4242
$where[] = ['check_status','=',$check_status];
4343
}
4444
if (!empty($search)) {
45-
$where[] = ['app_id','like',"%{$search}%"];
45+
//$where[] = ['app_id','like',"%{$search}%"];
4646
}
4747
if ($this->auth_group_id != 5 && !in_array($this->userId, config('app.ADMINISTRATOR'))) {
4848
$where[] = ['user_id', '=', $this->userId];

code/app/controller/Code.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function rescan(Request $request)
6767
Db::table('code_composer')->where(['code_id' => $id])->delete();
6868
Db::table('code_python')->where(['code_id' => $id])->delete();
6969
Db::table('code_java')->where(['code_id' => $id])->delete();
70+
Db::table('plugin_scan_log')->where(['app_id' => $id, 'scan_type' => 2])->delete();
7071

7172
return redirect($_SERVER['HTTP_REFERER']);
7273

code/app/controller/Config.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ public function del()
8282
}
8383
}
8484

85+
// 系统更新
8586
public function system_update()
8687
{
8788
$path = \think\facade\App::getRootPath() . '../';
8889
try {
89-
$cmd = "cd {$path} && git pull";
90+
$cmd = "cd {$path} && git config --global user.email 'you@example.com' && git config --global user.name 'Your Name' && git pull";
9091
$result = systemLog($cmd,false);
9192
$result = implode("\n", $result);
92-
$msg = '系统更新成功:'.$result;
93+
//$msg = '系统更新成功:'.$result;
9394

9495
// 更新sql语句
9596
$sqlPath = $path . 'docker/data';
@@ -111,10 +112,12 @@ public function system_update()
111112
Db::execute($sql.';');
112113
}
113114
}
115+
$version = $newVersion;
114116
file_put_contents($lock,$newVersion);
115117
}
116118
}
117119
}
120+
$msg = '系统更新成功,当前版本号:'.str_replace(".sql","",$version);
118121
} catch (\Exception $e) {
119122
$msg = '系统更新失败:'.$e->getMessage();
120123
}

code/app/controller/DeskIndex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function index()
5858

5959
##########
6060
//资产探测
61-
$hostCount = Db::table('one_for_all')->count();
61+
$hostCount = Db::table('host')->count();
6262
//端口数量
6363
$portCount = Db::table('host_port')->count();
6464
//服务数量

code/app/controller/Host.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
use app\model\AppModel;
77
use app\model\HostModel;
88
use app\model\UrlsModel;
9+
use app\Request;
910
use think\facade\Db;
1011
use think\facade\View;
1112

1213

1314
class Host extends Common
1415
{
1516

16-
public function index()
17+
public function index(Request $request)
1718
{
1819
$pageSize = 20;
1920
$where[] = ['is_delete','=',0];
@@ -24,6 +25,10 @@ public function index()
2425
if ($this->auth_group_id != 5 && !in_array($this->userId, config('app.ADMINISTRATOR'))) {
2526
$where[] = ['user_id', '=', $this->userId];
2627
}
28+
$app_id = $request->param('app_id');
29+
if (!empty($app_id)) {
30+
$where[] = ['app_id','=',$app_id];
31+
}
2732
$list = Db::table('host')->where($where)->order("id", 'desc')->paginate([
2833
'list_rows'=> $pageSize,//每页数量
2934
'query' => request()->param(),

code/app/controller/HostPort.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
use phpseclib3\File\ASN1\Maps\DSAPrivateKey;
1111
use think\facade\Db;
1212
use think\facade\View;
13+
use think\Request;
1314

1415

1516
class HostPort extends Common
1617
{
17-
public function index()
18+
public function index(Request $request)
1819
{
1920
$where[] = ['is_delete','=',0];
2021
$search = getParam('search',''); // 项目名称
@@ -40,6 +41,10 @@ public function index()
4041
if ($this->auth_group_id != 5 && !in_array($this->userId, config('app.ADMINISTRATOR'))) {
4142
$where[] = ['user_id', '=', $this->userId];
4243
}
44+
$app_id = $request->param('app_id');
45+
if (!empty($app_id)) {
46+
$where[] = ['app_id','=',$app_id];
47+
}
4348
$list = Db::table(HostPortModel::$tableName)->where($where)->paginate(10);
4449
$data = [];
4550
$data['list'] = $list->toArray()['data'];

0 commit comments

Comments
 (0)