Privilege Escalation Offensive Security Internal Recon Learning as

  • Slides: 16
Download presentation
Privilege Escalation Offensive Security

Privilege Escalation Offensive Security

Internal Recon • Learning as much as possible about the tagert • Hopefully find

Internal Recon • Learning as much as possible about the tagert • Hopefully find a path to escalate privileges • Many different ways to escalate Offensive Security Sometimes you need to get creative 2

Scripts • Lin. Enum https: //github. com/rebootuser/Lin. Enum • Unix privesc http: //pentestmonkey. net/tools/audit/unix-privesc-check

Scripts • Lin. Enum https: //github. com/rebootuser/Lin. Enum • Unix privesc http: //pentestmonkey. net/tools/audit/unix-privesc-check • Linprivchecker • Windows Exploits Suggester • Power. Up • post/windows/gather/enum_patches Offensive Security https: //github. com/reiderroque/linpostexp/blob/master/linprivchecker. py 3

Exploits • Exploiting the system itself Dirtycow • Figure out what’s running uname -a

Exploits • Exploiting the system itself Dirtycow • Figure out what’s running uname -a cat /proc/version cat /etc/issue Windows find patches wmic qfe get Caption, Description, Hot. Fix. ID, Installed. On Offensive Security • 4

Services Running Elevated • Some services may have access to run commands • Database

Services Running Elevated • Some services may have access to run commands • Database software (Multiple) Offensive Security Can execute shell commands What if this is running as root? We find creds via some other method 5

Stored Credentials • Finding creds somewhere on disk • Weak credentials • findstr /si

Stored Credentials • Finding creds somewhere on disk • Weak credentials • findstr /si password *. txt | *. xml | *. ini Offensive Security Config file Password manager database Saved in a browser C: unattend. xml C: sysprep. inf C: sysprep. xml 6

Sudo • Lower level user execute as higher level • Check which commands you

Sudo • Lower level user execute as higher level • Check which commands you are allowed to run • sudo -l Python Man Nmap Awk • https: //gtfobins. github. io/ Offensive Security Sudo su Other commands? 7

Unquoted Service Path • Service is running on Windows Service account has higher permissions

Unquoted Service Path • Service is running on Windows Service account has higher permissions Binary is writable by other users • Replace the binary with our own wmic service get name, displayname, pathname, startmode |findstr /i "Auto" |findstr /i /v "C: Windows\" |findstr /i /v """ Offensive Security Msfvenom binary 8

Insecure <> Permissions • Registry Permissions (Windows) Install a program Likely creates registry entries

Insecure <> Permissions • Registry Permissions (Windows) Install a program Likely creates registry entries Image. Path entry points to an executable Normal user has permissions to edit the registry key • Service Permissions • Cron jobs / Scripts run as root (Linux) Offensive Security Edit the service directly 9

 • Local Group Policy setting • If enabled, essentially makes all users admins

• Local Group Policy setting • If enabled, essentially makes all users admins • Msfvenom with msi format Offensive Security Always Install Elevated 10

Service only on localhost? • Services don’t have to be externally listening • Webservers,

Service only on localhost? • Services don’t have to be externally listening • Webservers, databases, etc • Don’t forget about exploits like Eternal blue Offensive Security Netstat crucial during internal recon Netstat –anlp 11

DLL Hijacking/Sideloading Application loads dynamic-link library without fully qualified path Windows searches defined directories

DLL Hijacking/Sideloading Application loads dynamic-link library without fully qualified path Windows searches defined directories https: //docs. microsoft. com/en-us/windows/desktop/Dlls/dynamic-linklibrary-search-order The directory from which the application loaded. The system directory. The 16 -bit system directory. The Windows directory. The current directory. The directories that are listed in the PATH environment variable. Offensive Security • 12

DLL Hijacking Process • Look at processes • Use procmon to determine DLL’s loaded

DLL Hijacking Process • Look at processes • Use procmon to determine DLL’s loaded Name not found error for. dll files Write our own DLL, name it, and place it in higher ranked directory Offensive Security • 13

Restricted Shell • Some shells have limited access We need a better shell Creating

Restricted Shell • Some shells have limited access We need a better shell Creating our own better shell python -c 'import pty; pty. spawn("/bin/bash")' Offensive Security • 14

And more… • UAC Bypass • Variations of permissions issues • Escaping restricted shell

And more… • UAC Bypass • Variations of permissions issues • Escaping restricted shell through other commands • Finding things laying around on the file system SSH key for the root account in the user account? Offensive Security Built into some common tools 15

 • https: //blog. g 0 tmi 1 k. com/2011/08/basic-linux-privilegeescalation/ • https: //rmusser. net/docs/Privilege%20

• https: //blog. g 0 tmi 1 k. com/2011/08/basic-linux-privilegeescalation/ • https: //rmusser. net/docs/Privilege%20 Escalation%20&%20 P ost-Exploitation. html#linpriv Offensive Security References 16