Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Console application geo-location

Here is my Geo-Location in a console source!
THIS CODE IS FOR A CONSOLE APPLICATION


PHP Code

<?php 
Imports System
.Net

Module Module1
    Sub Main
()
        
'///This try statment makes sure internet access is avliable
        Try
            My.Computer.Network.Ping("www.google.com")
        Catch ex As Exception
            MsgBox("Error: Internet is required!", MsgBoxStyle.Critical, "Error")
            Environment.Exit(-1)
        End Try

        '
///      IF YOU CHANGE THE CONSOLE BACKGROUND COLOR      ///
        
'///      CHANGE IT HERE ALSO   ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓        ///             
        While Console.BackgroundColor = ConsoleColor.Black
            Console.Title = "Console Geo-Locator By Dexuh"
            Console.ForegroundColor = ConsoleColor.Red



            '
///these are the variables needed for the geo-locator
            
Console.Write("Enter A IP Address: ")
            
Console.ForegroundColor = ConsoleColor.Green
            Dim IP 
As String = Console.ReadLine
            Dim wc 
As New WebClient()
            
Dim results As String = wc.DownloadString("http://api.predator.wtf/geoip/?arguments=" + IP)

            
'// This line is seperating each line
            Console.ForegroundColor = ConsoleColor.Blue
            results = results.Replace("<br>", vbNewLine)
            results = vbNewLine + results

            '
///this is desplaying the results
            
Console.WriteLine(results)

            
'///Asking if you want to geolocate another IP

            Console.ForegroundColor = ConsoleColor.Cyan
            Console.WriteLine(vbNewLine + "Press Enter to Geo-Locate Another IP")
            Console.ReadLine()
        End While

    End Sub


End Module 
[Image: F2G97kn.png]
Why the ping? Won't the webclient throw an exception if there is no internet connection? And don't you think the end user will check it himself? And why not use a using statement on the webclient so it automatically disposes of it afterwards? And why not see if the user actually inputted a valid IP string, and not some random gibberish?
(Dec 8, 2016 05:49 PM)Ninja Wrote:  Why the ping? Won't the webclient throw an exception if there is no internet connection? And don't you think the end user will check it himself? And why not use a using statement on the webclient so it automatically disposes of it afterwards? And why not see if the user actually inputted a valid IP string, and not some random gibberish?

The ping was to make sure the user has a internet connection. And i would add some more stuff but this is just a small source I made in 5 mins for HackForums
[Image: F2G97kn.png]
thanks so much mate i was need it lol !
(Dec 9, 2016 08:29 PM)Xogg Wrote:  The ping was to make sure the user has a internet connection. And i would add some more stuff but this is just a small source I made in 5 mins for HackForums

Yes but if the user has no internet connection the webclient will just throw an exception and you can handle that.
Oh true! did not think of that, Thanks! 🤝
[Image: F2G97kn.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by DASKJul 18, 2019 03:03 AM 1 152 Jul 18, 2019 03:03 AM
Last Post: Skofos
[.NET] by absojediMay 17, 2019 12:17 PM 1 179 May 17, 2019 12:17 PM
Last Post: StarZ
[C#] by VelvetCodingApr 17, 2019 09:39 PM 1 205 Apr 17, 2019 09:39 PM
Last Post: SIM-3991524