forked from gwen001/actarus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_scripts.php
182 lines (142 loc) · 4.44 KB
/
_scripts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
require_once( dirname(__FILE__).'/vendor/actarus/Config.php' );
// config
$config = Config::getInstance();
$config->actarusPath = dirname(__FILE__);
$config->appPath = $config->actarusPath.'/app';
$config->consolePath = $config->actarusPath.'/app/console';
$config->configPath = $config->appPath.'/config';
$config->logPath = $config->appPath.'/logs';
$config->loadParameters( $config->configPath.'/parameters.yml', 'parameters' );
$config->loadParameters( $config->configPath.'/myparameters.yml', 'parameters' );
//var_dump( $config );
//exit();
$db = $config->db = mysqli_connect( $config->parameters['database_host'], $config->parameters['database_user'], $config->parameters['database_password'], $config->parameters['database_name'] );
/*
function createSign( $url )
{
$url = urldecode( trim($url,' /') );
$sign = '';
$t_params = [];
$t_parse = parse_url( $url );
//var_dump( $t_parse );
if( isset($t_parse['query']) ) {
$t_query = explode( '&', $t_parse['query'] );
foreach( $t_query as $q ) {
if( strstr($q,'=') ) {
$tmp = explode( '=', $q );
$t_params[ $tmp[0] ] = $tmp[1];
} else {
$t_params[ $q ] = '';
}
}
ksort( $t_params );
}
//var_dump( $t_parse );
//var_dump( $t_params );
$str = str_replace( 's', '', $t_parse['scheme'] );
$str .= $t_parse['host'];
$str .= $t_parse['path'];
foreach( $t_params as $k=>$v ) {
$str .= $k;
$str .= $v;
}
//echo $str."\n";
$sign = md5( $str );
return $sign;
}
$q = "SELECT * FROM arus_request";
$r = $db->query( $q );
while( ($t=$r->fetch_object()) )
{
$sign = createSign($t->url);
$q = "UPDATE arus_request SET sign='".$sign."' WHERE id='".$t->id."'";
echo $q."\n";
$rr = $db->query( $q );
}
*/
/*
//$q = "SELECT * FROM arus_entity_task AS t WHERE command like 'nmap%' LIMIT 0,2";
$q = "SELECT * FROM arus_entity_task AS t WHERE command like 'nmap%'";
$r = $db->query( $q );
while( ($t=$r->fetch_object()) )
{
var_dump( $t->id );
$m = preg_match_all( '#([0-9]+)/([^\s]*)[\s]+open[\s]+([^\s]*)[\s]+(.*)\n#', $t->output, $matches );
if( !$m ) {
continue;
}
//var_dump( $matches );
$cnt = count( $matches[0] );
if( !$cnt ) {
continue;
}
$q = "SELECT * FROM arus_server AS s WHERE entity_id='".$t->entity_id."'";
$rr = $db->query( $q );
if( !$r || !$r->num_rows ) {
continue;
}
$s = $rr->fetch_object();
for( $i=0 ; $i<$cnt ; $i++ ) {
if( stristr($matches[4][$i],'service unrecognized') ) {
$matches[4][$i] = '';
}
$q = "INSERT INTO arus_server_service (server_id,port,type,service,version,created_at,updated_at) VALUES ('".$s->id."','".(int)$matches[1][$i]."','".$matches[2][$i]."','".$matches[3][$i]."','".$matches[4][$i]."',NOW(),NOW())";
echo $q."\n";
$db->query( $q );
}
}
*/
/*
$q = "SELECT * FROM arus_server AS s WHERE project_id='3' AND created_at>='2017-03-23 00:00:00'";
$r = $db->query( $q );
while( ($s=$r->fetch_object()) )
{
$cmd = $config->consolePath.' arus:task:create -t 23 -i '.$s->entity_id;
echo $cmd."\n";
system( $cmd );
}
*/
/*
$q = "SELECT h.* FROM arus_host as h left join arus_entity_task as t on h.entity_id=t.entity_id where t.command like 'testhttp%' and t.output like '%443:OK%'";
$r = $db->query( $q );
while( ($s=$r->fetch_object()) )
{
$cmd = $config->consolePath.' arus:task:create -t 42 -i '.$s->entity_id;
echo $cmd."\n";
system( $cmd );
}
*/
/*
$q = "SELECT h.* FROM arus_host as h WHERE h.project_id='331'";
$r = $db->query( $q );
while( ($s=$r->fetch_object()) )
{
$cmd = $config->consolePath.' arus:task:create -t 42 -i '.$s->entity_id;
echo $cmd."\n";
system( $cmd );
$cmd = $config->consolePath.' arus:task:create -t 40 -i '.$s->entity_id;
echo $cmd."\n";
system( $cmd );
}
*/
/*
$t_buckets = file( '/home/gwen/Sécurité/bug-bounty/h1-s3-buckets.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
var_dump( count($t_buckets) );
foreach( $t_buckets as $b )
{
$tmp = explode( '-', $b );
$q_select = "SELECT * FROM arus_project WHERE name LIKE '".$tmp[0]."'";
$r = $db->query( $q_select );
if( !$r || !$r->num_rows ) {
continue;
}
$project = $r->fetch_object();
$q_insert = "INSERT INTO arus_bucket (project_id,name,status,created_at,updated_at) VALUES ('".$project->id."','".$b."','0',NOW(),NOW())";
echo $q_insert."\n";
$db->query( $q_insert );
}
*/
$db->close();
exit( 0 );
?>