Use tcpdump to intercept msn communication data

Source: Internet
Author: User
#! /Bin/shechotemp.1echotemp. 3 # There is no limit on how many msn packet tcpdump-f-lnx-s0host192.168.0.1andport1863temp.0lines 'cattemp. 0 | wc-l 'line1while [$ line-le $ lines] do # get the time, ip address, and other information for memo.


#! /Bin/sh
Echo ""> temp.1
Echo ""> temp.3


# The number of msn packets is not limited here

Tcpdump-F-lnx-s 0 host 192.168.0.1 and port 1863> temp.0
Lines = 'cat temp.0 | wc-L'
Line = 1
While [$ line-le $ lines]
Do

# Obtain information such as the time-based ip address.

Memo = 'SED-n' "$ line" 'P' temp.0 | gawk '{if (!~ /^ 0x/) print ,,,,,,,,,,,""}''
Memo = $ "aaaaaaaa"
If ["$ memo" = "aaaaaaaa"]
Then

# Truncate the data part of a data packet

Out = 'SED-n' "$ line" 'P' temp.0 | cut-c "11-14, 16-19, 21-24, 26-29, 31-34, 36-39, 41-44, 46-49 "'
Echo-n "$ out"> temp.1
Else
Echo ""> temp.1
Out = 'SED-n' "$ line" 'P' temp.0 | gawk '{if (!~ /^ 0x/) print ,,,,,,,,,,,""}''
Echo-n "$ out"> temp.1
Fi
Line = 'expr $ line + 1'
Done
Echo ""> temp.1

# Delete empty rows and the first two rows

Sed '/^ &/d' temp.1 | sed '1, 2d'> temp.2
Lines = 'cat temp.2 | wc-L'
Line = 1
While [$ line-le $ lines]
Do

# Obtain realistic content
TIME = 'SED-n' "$ line" 'P' temp.2 | gawk '{print}' | gawk-F "." '{print }''
FROM = 'SED-n' "$ line" 'P' temp.2 | gawk '{print }''
TO = 'SED-n' "$ line" 'P' temp.2 | gawk '{print }''

# Determine and intercept msn data based on the flag

DATA0 = 'SED-n' "$ line" 'P' temp.2 | awk '{print}' | gawk-F "0d0a0d0a" '{print}' | sed '/^ 0d0a $/d' | sed's /.. /% &/g''

# Submit the intercepted UTF-8 hexadecimal number to the perl URI: Escape module for processing and displaying both Chinese and English

DATA = 'Perl-e "use URI: Escape; printuri_unescape ('$ data0 ');"'
Isnull = 'echo $ DATA | wc-M'
If [$ isnull-gt 1]
Then
Echo "$ FROM $ TO $ DATA: $"
Fi
Line = 'expr $ line + 1'
Done
Rm-f temp .*

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.