|
Ä¿ÇÇÇâÀÌ ³ª´Â *NIX
Ä¿ÇǴнº
½Ã½ºÅÛ/³×Æ®¿÷/º¸¾ÈÀ» ´Ù·ç´Â °÷
|
|
|
|
ÀÌÀü ÁÖÁ¦ º¸±â :: ´ÙÀ½ ÁÖÁ¦ º¸±â |
±Û¾´ÀÌ |
¸Þ½ÃÁö |
truefeel Ä«Æä °ü¸®ÀÚ
°¡ÀÔ: 2003³â 7¿ù 24ÀÏ ¿Ã¸° ±Û: 1277 À§Ä¡: ´ëÇѹα¹
|
¿Ã·ÁÁü: 2005.10.09 ÀÏ, 12:04 am ÁÖÁ¦: ruby¿Í pcapÀ¸·Î ³×Æ®¿÷ÆÐŶ ¸ð´ÏÅ͸µ |
|
|
Ruby¿Í Ruby/Pcap(libpcap ¹Ýµå½Ã ÇÊ¿ä)À» »ç¿ëÇÏ¿© ÆÐŶ ¸ð´ÏÅ͸µÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ ¼Ò°³Çϰí ÀÖ½À´Ï´Ù.
* Monitoring network traffic with Ruby and Pcap (By Ryan Paul , Ian Smith-Heisters , 2005.10.5)
http://arstechnica.com/columns/linux/linux-20051002.ars
¸ÕÀú http://www.goto.info.waseda.ac.jp/%7efukusima/ruby/pcap-e.html ¿¡¼ Ruby/PcapÀ» ¹Þ¾Æ¼ ¼³Ä¡Çϰí Å×½ºÆ®Çغ¸¸é µË´Ï´Ù.
ÄÚµå: |
# tar xvfz ruby-pcap-0.6.tar.gz
# cd pcap
#
# ruby extconf.rb
# make
# make install
|
¸î ÁÙ¸¸À¸·Î ÆÐŶ ¸ð´ÏÅ͸µ ÇÁ·Î±×·¥À» ¸¸µé ¼ö Àְڳ׿ä.
´ÙÀ½Àº À§ Ruby/Pcap ¶óÀ̺귯¸® Á¦°ø»çÀÌÆ®¿¡ ÀÖ´Â httpdump.rb ¿¹Á¦ÀÔ´Ï´Ù.
ÄÚµå: |
#!/usr/local/bin/ruby
require 'pcaplet'
httpdump = Pcaplet.new('-s 1500')
HTTP_REQUEST = Pcap::Filter.new('tcp and dst port 80', httpdump.capture)
HTTP_RESPONSE = Pcap::Filter.new('tcp and src port 80', httpdump.capture)
httpdump.add_filter(HTTP_REQUEST | HTTP_RESPONSE)
httpdump.each_packet {|pkt|
data = pkt.tcp_data
case pkt
when HTTP_REQUEST
if data and data =~ /^GET\s+(\S+)/
path = $1
host = pkt.dst.to_s
host << ":#{pkt.dst_port}" if pkt.dport != 80
s = "#{pkt.src}:#{pkt.sport} > GET http://#{host}#{path}"
end
when HTTP_RESPONSE
if data and data =~ /^(HTTP\/.*)$/
status = $1
s = "#{pkt.dst}:#{pkt.dport} < #{status}"
end
end
puts s if s
}
|
|
|
À§·Î |
|
 |
|
|
»õ·Î¿î ÁÖÁ¦¸¦ ¿Ã¸± ¼ö ÀÖ½À´Ï´Ù ´ä±ÛÀ» ¿Ã¸± ¼ö ÀÖ½À´Ï´Ù ÁÖÁ¦¸¦ ¼öÁ¤ÇÒ ¼ö ¾ø½À´Ï´Ù ¿Ã¸° ±ÛÀ» »èÁ¦ÇÒ ¼ö ¾ø½À´Ï´Ù ÅõÇ¥¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù
|
Powered by phpBB © 2001, 2005 phpBB Group
|