Showing posts with label packet. Show all posts
Showing posts with label packet. Show all posts

Wednesday, February 6, 2013

codegate 2012 prequal network 100

자, 패킷 포맷을 제대로 이해했다면 이제 실전에 적용해 보자.

실전에 적용해 보기 위해 아주 좋은 예제가 있다.

코드게이트 2012년 prequal 네트워크 100 문제~

파일 이름은 10_Floor.pcap으로 명명했다.

See on the link below to refer to pcap file format.

http://n20kim.blogspot.kr/2013/02/pcap-file-format.html

Wireshark can't open the pcap file.



If you understand pcap file format, you could notice what is weird.
Yeah, right!
pcap has global header at the beginning of the pcap. :)


# recover the pcap's global header.

1.make global header to add global header to the pcap.
   To make this, I made this code. It's simple but entering line by line is a little bit annoying

import binascii
binary=binascii.unhexlify("d4c3b2a1020004000000000000000000ffff000001000000")
f=open('header.pcap','w')
f.write(binary)
f.close()


2. add global header to the pcap



But an error still occurs because of size. phew...



Fix it again!

3. Did you notice something? The problem is size... and 22nd packet is normal.
   So you can infer that 23rd packet is probably abnormal.
   22nd packet byte streams is following:


4. The last line from 0x0038 is "16 d0 e3 42 ... "
    Find that byte streams in the 10_Floor.pcap
    23rd packet starts with "3e ec 60 ..".
    Packet header has 16bytes as you know.
    You can see "GET .." instead of packet header bytes. weird...
 
 
5. The final task is removing 23rd packet. Then you can open the pcap.




 

Saturday, December 1, 2012

[packet] ftp로 전송된 파일 추출


how to extract files from a  pcap file?

[+] Open the pcap files in WireShark

와이어 샤크에서 pcap 파일을 열자.
허벌나게 많은 패킷 중에서 ftp 파일만 보고 싶다. 고렇다면
expression에서 ftp-data를 찾아 filter를 걸어주거나


filter에 요렇게 "ftp-data"라고 필터를 건다!


[+] Extract a file from a pcap

ftp로 전송된 파일을 추출하고자 한다면 해당 패킷에서 우클릭 한 다음
"Follow TCP Stream"을 선택한다.

[+] Do you know the zip file format?

파일 구조를 자주 본 사람이라면 요걸 보고 딱! 느낌이 올 것이다.
그렇다. PK로 시작하는 헤더를 가진 파일 포맷... ZIP 파일이다.
just do "Save As" as a zip file.

ex) XXX.zip


참고로 아래는 실제 zip 파일을 hex editor로 열었을 때이다.
PK...로 시작한다는 거.