hoanhi
07-25-2008, 04:25 PM
Mik đang bắt tay vào viết chương trình Host Intrusion Detection System có chức năng Port Scan.
có điều mik lại k hiểu nhiều lắm về mạng nên gặp khó khăn. một số người bạn mik góp ý rằng nên tìm một phần mềm HIDS tương tự như AIDE, Trippwire, OSSEC để tham khảo và chỉnh sữa lại cho phù hợp với đề tài mik.
Mấy a chị có ai có ý kiến gì về đề tài mik vừa nói k? xin chỉ giúp mik với mik đang rất hoan mang lo sợ. thanks
alika
07-25-2008, 10:34 PM
Nếu chỉ để scan port mở hay đóng thì rất nhiều source code bạn có thể tham khảo bạn có thể search trên mạng đầy ra. Đây là 1 ví dụ đơn giản bạn có thể tham khảo
Title: Port Scanner for Visual Basic 2005 Express Edition
Author: David Kramer
Email: fireindy50@aim.com
Environment: VB Express 2005
Keywords: Port Scanner
Level: Begginner
Description: An article on how to scan for open ports.
Section Internet
SubSection General
http://www.codeproject.com/KB/vb/portscan/portscan.jpg
Introduction
This program scans for open ports. You supply a host, (ex: 192.168.1.1), and hit "Start" and the program scans.
Using the Code
'First declare or variables
Dim host As String
Dim port As Integer
Dim counter As Integer
Important Code
This is were most of the work is done. Next, we have a timer. As the timer ticks we are going to try to connect to the port, using a try/catch statement. If it connects, the port number is added to the 2nd listbox. If it does not connect, listbox1 adds an item with the port number saying its not open.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'Set the host and port and counter
counter = counter + 1 'counter is for the timer
TextBox2.Text = counter
host = TextBox1.Text
port = TextBox2.Text
' Next part creates a socket to try and connect on with the given user information.
Dim hostadd As System.Net.IPAddress = System.Net.Dns.GetHostEntry(host).AddressList(0)
Dim EPhost As New System.Net.IPEndPoint(hostadd, port)
Dim s As New System.Net.Sockets.Socket(System.Net.Sockets.Addre ssFamily.InterNetwork, _
System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
Try
s.Connect(EPhost)
Catch
End Try
If Not s.Connected Then
ListBox1.Items.Add("Port " + port.ToString + " is not open")
Else
ListBox1.Items.Add("Port " + port.ToString + " is open")
ListBox2.Items.Add(port.ToString)
End If
Label3.Text = "Open Ports: " + ListBox2.Items.Count.ToString
End Sub
Start Button
The next block of code is just starting the timer, and disabling/enabling buttons. Listbox1 adds text saying the host we are scanning.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add("Scanning: " + TextBox1.Text)
ListBox1.Items.Add("-------------------")
Button2.Enabled = True
Button1.Enabled = False
Timer1.Enabled = True
Timer1.Start()
End Sub
Form load and Stop Button
Again simple code of enabling/disabling controls
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button2.Enabled = False
TextBox2.Text = "0"
'set counter explained before to 0
counter = 0
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'stop button
Timer1.Stop()
Timer1.Enabled = False
Button1.Enabled = True
Button2.Enabled = False
End Sub
Points of Interest
Take a look at the sockets part. Sockets are useful for many things for connecting over the internet (etc.) This is my first article so I hope you like it.
License
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
hoanhi
07-25-2008, 10:44 PM
Theo như mik nghĩ thì đề tài mik k chỉ scan port thôi.
Nó là một chương trình phát hiện xâm nhập ở mức host (HIDS) có chức năng port scan tức là khi hacker dùng công cụ để scan port thì HIDS sẽ cảnh báo.
đó chỉ là suy nghĩ của mik nếu các anh chị có ý kiến gì xin góp ý giúp mik. thanks.