Packet Analysis

tags: Study

1100505

欄位名稱 運算元 數值資料
ip.geoip.xxx ==,>=,<= 10.x.x.x "Taiwan"
tcp.port in {80 443 8000}
ip.addr contains,matches "MZ","PE","(?i)Select.*"
    • (?i) 不管大小寫,但在wireshark下指令都要小寫
    • check abnormal : (not ip.geoip.country == "Taiwan") and (not tcp.port in {80 443 8080 8000})
    • tcp.flags.syn == 1 or dns(有Fin ack傳輸)
    • 可用not ip.geoip.asnum in {8068 8070 8075 15169 3462} 去除微軟等重要公司封包
    • (not (ip.src==10.0.0.0/16 and ip.dst == 10.0.0.0/16)) 去除內網封包 ※前面ip要改
    • 不看內網SMB tcp.port in{139 445} and (not (ip.src == 10.0.0.0/16 and ip.dst == 10.0.0.0/16))
  • 不同設備錄封包

    • AirPcap 無線網路未落地封包側錄 (隨身碟) + Wireshark
    • 手機錄封包(使其連wi-fi)
  • TCP偽冒(※除了TCP以外均可偽冒)

    • TCP無法偽冒別的網站(因為SYN過去之後,ACK會透過DNS及Router Table回真正的網站);除非Router結構要改
    • 内網沒有Gateway,沒有Router所以可以偽冒
    • 運用UDP偽冒IP,可以達成DDos等攻擊(讓封包狂吐回真正網站)
  • ARP Protocal => NIC send ARP Packet to ask MAC-Address ;Only LAN

  • DNS 封包 => 成雙成對,※正常:1問1答;異常:1問多答、無問有答「DNS欺騙(DNS Spoofing)」、有問無答(為DNS設錯)

  • 惡意封包

    • SYN(灰色)通常傳送時間間隔固定、固定時間連線(如08-17)
    • mmc => open system32\taskschd 看工作排程 或是看 啟動
    • 放在啟動不用管理者權限、工作排程要權限!!
    • 1.regedit 2.服務 3.工作排程 4.開始程式集 5.Device Driver
    • 程式保護:放在啟動、工作排程、系統檔案隱藏、讓使用者拒絕寫入
    • ※ADS 替代資料流(專門欺騙windows,為了相容mac) (NTFS交換資料流(Alternate Data Streams,簡稱ADS)) dir /R /Q 可以顯示隱藏資料流
notepad.exe aaa.txt:abc.cmd //在原有檔案後面加冒號;.cmd (windows指令碼)

1100505

※第二排,如果為Admin即為該帳號,如為Administrator則有被提權過

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


屬性改成隱藏,會讓Dir之類的看不到!Great

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


內容->動作 可以讓其暫停

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


有裝GeoLite2的話可以看Map!!

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Reference

Hacker definition 集各種木馬、zero-day漏洞滲透別人,而不是只賣產品QQ"
mimikatz(kali) 偷帳密
ANY.RUN(Malware hunting website) => 右上角放大鏡可以輸入種類 Ex:trojan
CertUtil -hashfile Client-built.bin MD5、SHA1、SHA256
副檔名用.scr也可以當作.exe執行;用很多空白把.exe藏到後面去~
schtasks 工作排程指令
不規則的封包才是正常,太規則常為異常。
Asnum -> 全球公司統一代碼
bazaar.abuse.ch 其中一個malware database
Dharma、CryptBot 加密勒索
23401 port NvBackend.exe 有機會可以當漏洞
流量不代表安不安全 Flow not corresspond with Security
Software->Microsoft->CurrentVersion->Run->路徑 (放在啟動裡面)
:::

11000506

  • WireShark指令

    • Statistics -> http -> Packet Counter ※正常Http Request與Response要匹配
    • Preference -> Protocals -> TLS -> 選Session Log檔
    • http2 -> https透過Session Key解出來的東西
  • 網站弱點掃描特徵-1

    • 相同用戶端IP位址,短時間內大量傳送HEAD、OPTIONS、TRACE指令。此為網站弱點掃描特徵。
    • Nessus等弱掃軟體
  • 網站弱點掃描特徵-2

  • 相同用戶端IP位址,傳送HTTP指令後,產生回應直404(大量),此為弱點掃描特徵,但是下列檔案存取的404不列入計算:1.robots.txt、2.favicon.ico(網站縮圖)

  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

    • 正常網站要加入:robots.txt => 搜尋引擎的規範(避免Google hacking抓東西)
  • SQL-Injection特徵-1

  • 相同網頁,多數瀏覽器皆可正常顯示,惟有少數IP位址,瀏覽此網頁會產生HTTP回應值5XX,此為SQ-Injection特徵(有人在做指令測試,所以產生伺服器回應指令失敗)

  • SQL-Injection特徵-2

  • HTTP的指令參數中,含有:

    • 1.特殊字元符號
    • 2.SQL指令
  • HTTP Response Status Code

    • 1xx:在三項交握之前,Server尚在處理其他事件,故會先發送100給Client端 (for 硬體介面回應)
  • Upnp、SSDP封包(類似Http封包) => 80、1900、2869 port //info M-SEARCH(無線分享器詢問有沒有無線設備的連線)

  • 0.0.0.0 => invaild address (為設備剛開機,廣播獲取DHCP)

可以隱藏成系統保護檔案

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

ADS 替代資料流

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Reference

dir /AH (Attribute Hide) /AS(Attribute System) (隱藏保護的作業系統檔案)
Web-CGI(common gateway interface)
WAF (Web Application Firewall) ->只能檔外面一層,原本SQL指令沒改,還是會入侵
WAF 真正的功用為,暫時性擋住攻擊,讓Programmer有時間改SQL指令
WAF Bypass

Tor 洋蔥瀏覽器 (類似三層跳板瀏覽器) (Port 9001-9999)

美國政府專案(為了讓異議人士退翻海珊)
林沖的例子,官逼民反;洋蔥瀏覽器原本不是给暗網用的,一開始是政府工具後來才淪落到暗網
TOR Search .onion List
10 Best Tor Websites To Visit Today - Surfshark(Ahmia ← 這才是真正的暗網瀏覽器 )
暗網裡面的其他網站,也是隔了很多跳板才會跳到那個Server
不要在暗網裡面下載任何東西
可以將瀏覽器導至Tor.exe再傳送出去

Tor-Onion-List

http://darksidc3iux462n6yunevoag52ntvwp6wulaz3zirkmh4cnz6hhj7id.onion

http://avaddongun7rngel.onion

http://nbzzb6sa6xuura2z.onion

http://rnsm777cdsjrsdlbs4v5qoeppu3px6sb2igmh53jzrx7ipcrbjz5b2ad.onion

http://hpoo4dosa3x4ognfxpqcrjwnsigvslm7kv6hvmhh2yqczaxy3j6qnwad.onion (Dopple leaks);Latest proof(證明已入侵)、Latest Leak(結案、給錢或資料洩漏)
http://dnpscnbaix6nkwvystl3yxglz7nteicqrou3t75tpcc5532cztc46qyd.onion
(happy blog)

解洋蔥路由

錄 loopback(127.0.0.1) 封包


基礎知識

A: '或"代表字串 => C Series
B: ;代表程式碼結束或隔開 => C Series,Java
C: //,//,#,ASM都是代表註解
D: Exec或eXec代表SQL執行巨集(macro)
E: xp-cmdshell代表MS-SQL的cmd.exe =>只有disable
F: net user xxx /option (add、delete) 代表Win新增帳號
G: net localgroup administrators xxx /option (add、delete)

程式設計裡面,只要有迴圈、判斷、變數,都盡量用註解讓人家了解(ex:變數不要只設i)

較老通訊協定(效率差) 中生代通訊協定(效率好)
FTP HTTP SMB
SMTP HTTPS IP
POP UPnP
Telent SSDP

SCADA(工業用協定):DNP、ModBus
特斯拉車用協定:CAN-BUS =>


SQL injection (要先看網站有沒有帶參數(資料夾後面接?)

1: ';或";或; (看那個網站對'或是"哪個有反應,有沒有限制錯誤..等)
2: SQL指令
3: ;
所有SQL injection都是做以上三件事情,把前後指令結束,中間插我們要的指令

site:org.tw inurl:news.asp

環境變數拿Session Key

https://medium.com/blacksecurity/用wireshark-解析使用者瀏覽器https流量教學-8c15948f38fd


漏洞資料庫 -> 有各種PoC Source_Code ※一個大秘寶!! (Exploit、Shellcode、Paper)
https://www.exploit-db.com/


SMB基本規則

  • 在正常情況下,網路芳鄰SMB/NBNS協定,僅應連結內部網路(LAN),亦即不應連接到Internet,若SMB/NBNS的發送端或接收端IP位址為WAN位址則為異常。

網路芳鄰UDP封包特性

  • 網路芳鄰的UDP封包其發送端(Src)port編號與接收端(Dst)port編號應相符合。若不符合而發送端作業系統為Windows系統則為異常通訊。

SMB

  • 美國軍方規定:在網路上不傳密碼,只傳密碼的Hash值做比對(shadow)。

ARP Spoofing

  • 在Lan裡面,只看Mac比IP重要。

tshark 教學

  • 1.指令操作 tshark -r xxx.pcap -Y "tcp.port in(139 445)" -w Result.pcap

網路芳鄰$的符號為預設開放 net share

NetBIOS停用
1.關Client for Microsoft Networks、File and Printer Sharing for Microsoft Networks
2.IPV4 → 進階 → WINS → 停用

如何找網路芳鄰

Reference

基礎知識

State (FT、IMAP、POP3等)有態通訊 => 前後有關連 (因為要Log in)
Stateless (HTTP) 無態通訊 = > 前後無關聯
Worm蠕蟲 => 通常為(Buffer Overflow)
Telnet => 未加密的點對點連線
SSH => 加密點對點連線
CIFS / SMB(Server Message Block) =>(IBM寫的) 網路芳鄰 =>(Microsoft) TCP、 NBNS 為 UDP ; Port TCP:139、445,UDP:135-138
Linux系統沒有內建SMB(所以Linux的SMB是一般的程式,可以被殺掉)
駭客練習,從舊的開始打~ XP、2008R2等。
insider n.內賊、洩密者
Shodan -> SMB -> 連線網路磁碟 \IP\disk
ARP 找MAC時,Switch會全部閃一下(廣播找Mac)
Broadcast => 現在叫做網路探索~
SQL injection Trojan drop
Spyware 儲存網路足跡
野史