forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nmap.index.php
executable file
·257 lines (188 loc) · 7.12 KB
/
nmap.index.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
include_once('ressources/class.templates.inc');
include_once('ressources/class.ldap.inc');
include_once('ressources/class.nmap.inc');
include_once('ressources/class.artica.inc');
include_once('ressources/class.ini.inc');
$user=new usersMenus();
if($user->AsSystemAdministrator==false){header('location:users.index.php');exit();}
if(isset($_POST["NmapScanEnabled"])){main_settings_edit();exit;}
if(isset($_GET["tabs"])){tabs();exit;}
if(isset($_GET["parameters"])){parameters();exit;}
if(isset($_GET["events"])){events();exit;}
if(isset($_GET["NMAP_EVENTS"])){NMAP_EVENTS();exit;}
if(isset($_POST["DeleteAllNMAPEV"])){events_delete_all();exit;}
if(isset($_GET["ScanNow"])){main_scan();exit;}
js();
function js(){
$page=CurrentPageName();
$tpl=new templates();
$title=$tpl->_ENGINE_parse_body("{APP_NMAP}");
$html="YahooWin3('1050','$page?tabs=yes','$title')";
echo $html;
}
function tabs(){
$page=CurrentPageName();
$array["parameters"]='{parameters}';
$array["events"]='{events}';
$tpl=new templates();
$fontsize="style='font-size:22px'";
while (list ($num, $ligne) = each ($array) ){
$html[]=$tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=yes&ID={$_GET["ID"]}\"><span $fontsize>$ligne</span></a></li>\n");
}
echo build_artica_tabs($html, "main_config_nmap");
}
function NMAP_EVENTS(){
// $findcomputer="{name: '$scan_your_network', bclass: 'ScanNet', onpress : ScanNet},";
$ID=$_GET["NMAP_EVENTS"];
if(!is_numeric($ID)){echo "NOT A NUMERIC";die();exit;}
$page=CurrentPageName();
$tpl=new templates();
$q=new mysql();
$sql="SELECT * FROM nmap_events WHERE ID='$ID'";
$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_events'));
$ligne["text"]=htmlspecialchars($ligne["text"]);
$ligne["text"]=str_replace("\n", "<br>", $ligne["text"]);
$html="<div style='font-size:16px'>{$ligne["subject"]}</div><div style='font-size:13px;height:550px;overflow:auto' class=form>{$ligne["text"]}</div>";
echo $html;
}
function events(){
$sock=new sockets();
$page=CurrentPageName();
$tpl=new templates();
$q=new mysql();
$html="
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
<tr>
<th width=1%>". imgtootltip("refresh-24.png","{refresh}","RefreshTab('main_config_nmap')")."</th>
<th width=1%>{date}</th>
<th width=1%> </th>
<th width=99%>events</th>
<th width=1%>". imgtootltip("delete-32.png","{delete_all}","DeleteAllNMAPEV()")."</th>
</tr>
</thead>
<tbody class='tbody'>";
$sql="SELECT subject,zDate,ID,uid FROM nmap_events ORDER BY zDate DESC LIMIT 0,300";
$results=$q->QUERY_SQL($sql,"artica_events");
if(!$q->ok){echo "<H2>$q->mysql_error</H2>";}
while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
$view=" ";
if($ligne["uid"]<>null){$view=imgtootltip("computer-32.png","{view}",MEMBER_JS($ligne["uid"],1,1));}
$color="black";
$link="<a href=\"javascript:blur();\" OnClick=\"javascript:NMAP_EVENTS({$ligne["ID"]})\" style='font-size:12px;text-decoration:underline'>";
$html=$html."
<tr class=$classtr>
<td style='font-size:12px;font-weight:bold;color:$color' width=1% nowrap colspan=2>{$ligne["zDate"]}</a></td>
<td style='font-size:12px;font-weight:bold;color:$color' width=1% nowrap>$view</a></td>
<td style='font-size:12px;font-weight:bold;color:$color' width=99% nowrap colspan=2>$link{$ligne["subject"]}</a></td>
</tr>
";
}
$html=$html."
</tbody>
</table>
<script>
function NMAP_EVENTS(ID){
YahooWin4('650','$page?NMAP_EVENTS='+ID,ID);
}
var x_DeleteAllNMAPEV= function (obj) {
var results=obj.responseText;
RefreshTab('main_config_nmap');
}
function DeleteAllNMAPEV(){
var XHR = new XHRConnection();
XHR.appendData('DeleteAllNMAPEV','yes');
XHR.sendAndLoad('$page', 'POST',x_DeleteAllNMAPEV);
}
</script>";
echo $tpl->_ENGINE_parse_body($html);
}
function parameters(){
$sock=new sockets();
$page=CurrentPageName();
$tpl=new templates();
$NmapRotateMinutes=$sock->GET_INFO("NmapRotateMinutes");
$NmapScanEnabled=$sock->GET_INFO("NmapScanEnabled");
$NmapTimeOutPing=intval($sock->GET_INFO("NmapTimeOutPing"));
if($NmapTimeOutPing==0){$NmapTimeOutPing=15;}
if(!is_numeric($NmapScanEnabled)){$NmapScanEnabled=1;}
if(!is_numeric($NmapRotateMinutes)){$NmapRotateMinutes=60;}
if($NmapRotateMinutes<5){$NmapRotateMinutes=5;}
$findcomputer=Paragraphe("64-samba-find.png","{scan_your_network}",'{scan_your_network_text}',"javascript:Loadjs('computer-browse.php?scan-nets-js=yes')","scan_your_network",210);
$html="
<div id='nmapidset' style='width:98%' class=form>
<table style='width:100%'>
<tbody>
<tr>
<td colspan=2>
". Paragraphe_switch_img("{NmapScanEnabled}", "{about_nmap}","NmapScanEnabled",$NmapScanEnabled,null,750)."
</td>
<tr>
<td class=legend style='font-size:18px'>{NmapRotateMinutes}:</td>
<td valign='top' nowrap style='font-size:18px'>" . Field_text('NmapRotateMinutes',$NmapRotateMinutes,'font-size:18px;width:90px')." {minutes}</td>
</tr>
<tr>
<td class=legend style='font-size:18px'>{timeout_ping_networks}:</td>
<td valign='top' nowrap style='font-size:18px'>" . Field_text('NmapTimeOutPing',$NmapTimeOutPing,'font-size:18px;width:90px')." {seconds}</td>
</tr>
<tr>
<td colspan=2 align='right'><hr>". button("{apply}","SaveNMAPSettings()",32)."</td>
</tr>
</tbody>
</table>
</div>
<script>
var x_AddComputerToDansGuardian= function (obj) {
var mid='ip_group_rule_list_'+rule_mem;
LoadAjax(mid,'dansguardian.index.php?ip-group_list-rule='+rule_mem);
}
var x_SaveNMAPSettings= function (obj) {
var results=obj.responseText;
RefreshTab('main_config_nmap');
}
function SaveNMAPSettings(){
var XHR = new XHRConnection();
XHR.appendData('NmapRotateMinutes',document.getElementById('NmapRotateMinutes').value);
XHR.appendData('NmapScanEnabled',document.getElementById('NmapScanEnabled').value);
XHR.appendData('NmapTimeOutPing',document.getElementById('NmapTimeOutPing').value);
XHR.sendAndLoad('$page', 'POST',x_SaveNMAPSettings);
}
</script>
";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function main_settings_edit(){
$sock=new sockets();
$sock->SET_INFO("NmapRotateMinutes", $_POST["NmapRotateMinutes"]);
$sock->SET_INFO("NmapScanEnabled", $_POST["NmapScanEnabled"]);
$sock->SET_INFO("NmapTimeOutPing", $_POST["NmapTimeOutPing"]);
}
function main_events(){
$html="<H3>{nmap_logs}</H3><div id='nmap_events'>".main_events_fill()."</div>";
$tpl=new templates();
echo $tpl->_ENGINE_parse_body($html);
}
function main_events_fill(){
$datas=@explode("\n",file_get_contents(@dirname(__FILE__).'/ressources/logs/nmap.log'));
if(is_array($datas)){
$datas=array_reverse($datas);
while (list ($num, $ligne) = each ($datas) ){
if(trim($ligne)<>null){
$ev[]=$ligne;
}
}
}
return "<textarea style='border:0px;font-size:10px;width:100%' rows=50>".@implode("\n",$ev)."</textarea>";
}
function events_delete_all(){
$q=new mysql();
$q->QUERY_SQL("TRUNCATE TABLE nmap_events","artica_events");
}
function main_scan(){
$sock=new sockets();
$sock->getfile('NmapScanNow');
}
?>