Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IP ban People Visual Basic
11-28-2009, 07:27 AM
Post: #1
IP ban People Visual Basic
This can be useful for the ones who have sites :
1. Create the following text files on a webserver where you can access them from anywhere:
bans.txt = put in the IP's of the people you want banned.
reason.txt = put in the reason you disabled the hack
macbans.txt = put in the macs of the ppl u want banned
enable.txt = 1 for enabled, 0 for disabled. Nothing else.
2. Create a new VB.net Project, or open up your program.
3. Put this code in Form_Load.
Code:
Dim IP As String
    Dim Bans() As String
    'GETS THE PERSONS IP
    Dim req As HttpWebRequest = WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
    Dim res As HttpWebResponse = req.GetResponse()
    Dim Stream As Stream = res.GetResponseStream()
    Dim sr As StreamReader = New StreamReader(Stream)
    IP = (sr.ReadToEnd())
    'checks to see if you are banned.
    Bans = Split(GetWebSiteSource("http://www.yourdomain.com/bans.txt"), vbCrLf)
    If Bans.Length > 0 Then
        Dim x As Long
        For x = 0 To Bans.Length - 1
            If IP = Bans(x) Then
                MsgBox("You have been banned. Contact me, Youremail@domain.com, to see why.")
                'this delays the deletion WHILE the program exits. You cant use sleep for this, because the program would still have to be open.
            Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 1000 > Nul & Del " + Application.ExecutablePath)
                Me.Close()
            End If
        Next x
    End If
This next Code is if you want the program to email you every time somebody starts it up. It lags the program for like 5-10 seconds before start up, and makes it look like it has frozen. So I put a splash screen with this on it :
Code:
Imports System.IO
    Imports System.Net
    Imports System.Net.Mail
    Imports System.Net.NetworkInformation
    
    Public Class Form3
        Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        Private Sub Form3_Show(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            StartUp()
        End Sub
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'shows form1
            Form1.Show()
            Me.Close()
        End Sub
           'for getting site source
        Public Function GetWebSiteSource(ByVal URL As String) As String
            Dim request As System.Net.HttpWebRequest = System.Net.WebRequest.Create(URL)
                Dim response As System.Net.HttpWebResponse = request.GetResponse
            Dim reader As New System.IO.StreamReader(response.GetResponseStream)
            Return reader.ReadToEnd
        End Function
        Private Sub StartUp()
            Dim IP As String
                Dim Enabled As String
            Dim reason As String
            Dim Bans() As String
            Dim Mac As String
            Dim txtMac As String = "Mac: "
            Dim txtIP As String = "IP: "
            Dim space As String = "    "
        Dim MacBans As String
            Dim MacBansList() As String
            Try
                Dim nic As NetworkInterface = Nothing
                Dim mac_Address As String = ""
                For Each nic In NetworkInterface.GetAllNetworkInterfaces
                    mac_Address = nic.GetPhysicalAddress().ToString
                    If mac_Address <> "" Then
                        Mac = mac_Address
                    End If
                Next
                nic = Nothing
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            'GETS THE PERSONS IP
            Dim req As HttpWebRequest = WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
            Dim res As HttpWebResponse = req.GetResponse()
            Dim Stream As Stream = res.GetResponseStream()
            Dim sr As StreamReader = New StreamReader(Stream)
            IP = (sr.ReadToEnd())
            'checks to see if you are banned.
            Bans = Split(GetWebSiteSource("http://yourdomain.com/bans.txt"), vbCrLf)
            If Bans.Length > 0 Then
                Dim x As Long
                For x = 0 To Bans.Length - 1
                    If IP = Bans(x) Then
                        MsgBox("You have been banned. Contact me, youremail@domain.com, to see why.")
                        Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 1000 > Nul & Del " + Application.ExecutablePath)
                        Me.Close()
                    End If
                Next x
            End If
            MacBansList = Split(GetWebSiteSource("http://yourdomain.com/macbans.txt"), vbCrLf)
            If MacBansList.Length > 0 Then
                Dim x As Long
                For x = 0 To MacBansList.Length - 1
                    If MacBans = MacBansList(x) Then
                        MsgBox("You have been banned. Contact me, YOUREMAIL@GMAIL.COM, to see why.")
                        Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 1000 > Nul & Del " + Application.ExecutablePath)
                        Me.Close()
                    End If
                Next x
            End If
    
    
            'checks to make sure program is not disabled.
            Sleep(500)
            Me.Show()
        Enabled = GetWebSiteSource("http://halotrialdownloads.webs.com/enable.txt")
            'gets reason program was disabled.
        reason = GetWebSiteSource("http://halotrialdownloads.webs.com/Reason.txt")
            If Enabled = "0" Then
                MsgBox("THIS PROGRAM HAS BEEN DISABLED. REASON:" & reason)
                Process.Start("cmd.exe", "/C ping 1.1.1.1 -n 1 -w 1000 > Nul & Del " + Application.ExecutablePath)
                Me.Close()
            End If
            'EMAILS YOU THE IP AND MAC OF THE USER.
            Dim smtpserver As New SmtpClient()
            Dim mail As New MailMessage()
            smtpserver.Credentials = New Net.NetworkCredential("uremail@domain.com", "yourpassword")
            smtpserver.Host = "smtp.gmail.com or something else"
            smtpserver.Port = 587 'or something else
            mail = New MailMessage
            mail.From = New MailAddress("uremail@domain.com")
            mail.To.Add("uremail@domain.com")
            mail.Subject = "TUTORIAL THING. CHANGE THIS."
            mail.Body = txtIP & IP & space & txtMac & Mac
            smtpserver.EnableSsl = True
        Try
            smtpserver.Send(mail)
            Catch ex As Exception
    
            End Try
        End Sub
    End Class
Don't forget to change certain values inside of the code !

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
12-20-2009, 11:19 AM
Post: #2
RE: IP ban People Visual Basic
Pretty cool but I would do it a little different, I like your method of sending the emails though, very efficient, you could however simply add a new thread for it to operate on the avoid the lagging...

Anyways, for to check if they are banned I would;
1. I prefer to keep it local but I will use the same site as you (http://whatismyip.com/automation/n09230945.asp)
2. Have all the banned IP's on a text file and check to see if it is within

Im not saying its better it is just how I would do it, it makes a bit easier to read and a bit neater rather than waiting for a response from the server.

Code:
Imports System.Net
Imports System.Text
Imports System.Windows.Forms

Module Banned
    Sub Main()
        If Banned() = True Then
            Console.WriteLine("I AM BANNED!!!")
            ' Send email code...
            Console.ReadLine() ' Wait for key
            Application.Exit() ' Quit
        Else
            Console.WriteLine("Welcome!")
            Console.ReadLine() ' Display output.
            ' Do normal stuff...
        End If
    End Sub

    Function Banned() As Boolean
        Dim myWebClient As New WebClient
        Dim bannedList As String ' Will contain our remote banned ip's
        Dim myIP As String ' Will contain ip from remote address

        bannedList = Encoding.ASCII.GetString(myWebClient.DownloadData("http://freckles.projectghostt.com/banned/banned.txt")) ' Read the page
        myIP = Encoding.ASCII.GetString(myWebClient.DownloadData("http://whatismyip.com/automation/n09230945.asp")) ' Read the page

        If bannedList.Contains(myIP) Then
            Return True ' We banned
        Else
            Return False ' Not banned
        End If
    End Function
End Module

[Image: pgsig copy.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-20-2009, 11:12 PM
Post: #3
RE: IP ban People Visual Basic
Yeah surely this is faster way !
Good function you wrote there i can say.
So i don't need to use HttpWebRequest which is good.

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
12-21-2009, 07:39 AM
Post: #4
RE: IP ban People Visual Basic
Yeah, some of the stuff I have posted here uses .downloadfile which is lame as you then bring in troubles of an external file for modification. Always better to keep it local - more control.

[Image: pgsig copy.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: