Register - Login
Views: 99830196
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
05-03-22 09:08:24 PM
Jul - Computers and Technology - [VB08] IP / MAC Address change not working? New poll - New thread - Thread closed
Next newer thread | Next older thread
Multi-voting is disabled. 0 users have voted.

ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 60/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 05-02-11 08:24:14 PM Link

 

Private Function GetMACAddress(ByVal Adapter As String) As String
Dim mc As System.Management.ManagementClass
Dim mo As Management.ManagementObject
mc = New Management.ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As Management.ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)
If strAdapter = Adapter Then
Return mo.Item("MacAddress").ToString()
End If
End If
Next
End Function

[/code

The End function says in green that it can't return value on All code paths.

This is the WHOLE code ot the program.


[Code]
Option Explicit On
Imports System.Management
Imports System.Net
Imports System.Net.NetworkInformation
Public Class Form1
Dim bool As Boolean = True
Private Function GetMACAddress(ByVal Adapter As String) As String
Dim mc As System.Management.ManagementClass
Dim mo As Management.ManagementObject
mc = New Management.ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As Management.ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)
If strAdapter = Adapter Then
Return mo.Item("MacAddress").ToString()
End If
End If
Next
End Function

Public Sub gateway1()
Dim gatewayip As String
Dim l As Integer = 0
Dim arr(l) As String

Dim myNetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
Dim myAdapterProps As IPInterfaceProperties = Nothing
Dim myGateways As GatewayIPAddressInformationCollection = Nothing

For Each adapter As NetworkInterface In myNetworkAdapters
myAdapterProps = adapter.GetIPProperties

myGateways = myAdapterProps.GatewayAddresses

For Each Gateway As GatewayIPAddressInformation In myGateways
gatewayip = Gateway.Address.ToString
arr(l) = gatewayip
TextBox6.Text = Gateway.Address.ToString
'l += 1
Next
Next
' MsgBox(arr(0))
WebBrowser2.Navigate(TextBox6.Text)
End Sub
Private Sub FillNetworkAdapters()
Dim mc As System.Management.ManagementClass
Dim mo As Management.ManagementObject
mc = New Management.ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As Management.ManagementObjectCollection = mc.GetInstances()
For Each mo In moc
If mo.Item("IPEnabled") = True Then
Dim strAdapter As String
strAdapter = mo.Item("Caption").ToString().Substring(11)

combo_network.Items.Add(strAdapter)
End If
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Timer7.Enabled = True


FillNetworkAdapters()
gateway1()

WebBrowser3.Visible = False
WebBrowser4.Visible = False

WebBrowser3.Navigate("http://www.ipligence.com/geolocation")
WebBrowser4.Navigate("http://www.batchgeocode.com/lookup/")

Timer3.Enabled = True
Timer5.Enabled = True

TextBox1.Text = System.Net.Dns.GetHostName
Me.Text = "Wait..."
WebBrowser1.Navigate("http://www.whatismyip.com/tools/ip-address-lookup.asp")
bool = False
TextBox3.Text = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList(0).ToString()
Dim mac As String
Dim l As Integer = 0
Dim br(l) As String
For Each nic As System.Net.NetworkInformation.NetworkInterface In System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
'MessageBox.Show(String.Format("The MAC address of {0} is{1}{2}", nic.Description, Environment.NewLine, nic.GetPhysicalAddress()))
mac = String.Format("{2}", nic.Description, Environment.NewLine, nic.GetPhysicalAddress()).ToString
Try
br(l) = mac
Catch ex As Exception
End Try
l += 1
Next
TextBox4.Text = br(0)
mac_text.Text = br(0)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If WebBrowser1.IsBusy = False Then
adresa()
Timer1.Enabled = False
End If
End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.IsBusy = False And bool = False Then
Timer1.Enabled = True
bool = True
End If
End Sub
Public Sub adresa()
Try
TextBox2.Text = WebBrowser1.Document.All("IP").GetAttribute("value")
Me.Text = "IPChanger"
Catch ex As Exception
MsgBox("You are not connected to internet!")
Me.Text = "IPChanger"
End Try

End Sub

Private Sub Info_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub


Private Function DoPadding(ByVal x As String) As String
Dim Ret As String
Dim z As Integer

Ret = x
If Len(x) < 4 Then
For z = 1 To 4 - Len(x)
Ret = "0" & Ret
Next
End If

Return Ret
End Function
Private Sub ShowRestart()
Dim res As MsgBoxResult = MsgBox("Your MAC address is changed. You need to restart your computer or turn off and turn on your router.", MsgBoxStyle.Information)
End Sub

Private Sub ChangeMac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChaneMac.Click

If IsOkay() = False Then
Exit Sub
End If
Try
Catch ex As Exception
MsgBox("Error! Try again.")
Dim regKey As Microsoft.Win32.RegistryKey
Dim Addr As String = GetRoot(combo_network.SelectedItem.ToString)

regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Addr, True)

regKey.SetValue("NetworkAddress", mac_text.Text.Replace(":", ""))
ShowRestart()
End Try

End Sub

Private Function GetRoot(ByVal Adapter As String) As String
Dim regKey As Microsoft.Win32.RegistryKey
Dim i As Integer = 1

Do
Dim Root As String = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}"
Dim Last As String = DoPadding(i)
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Root & Last, True)

Try
Dim cAdapter As String = regKey.GetValue("DriverDesc").ToString()
If cAdapter = Adapter Then

Return Root & Last

Exit Do
End If
Catch ex1 As Exception
MsgBox("Error! Try again.")
End Try
i += 1
Loop
End Function

Private Function IsOkay() As Boolean
If mac_text.Text = "" Then
MsgBox("You have not enterd new MAC address!", MsgBoxStyle.Critical)
Return False
End If

Dim ed As String = mac_text.Text.Replace(":", "")

If ed.Length <> 12 Then
MsgBox("MAC address have to be in 12 characters!", MsgBoxStyle.Critical)
Return False
End If

Try
If combo_network.SelectedItem.ToString = "" Then
MsgBox("You have not select a router!", MsgBoxStyle.Critical)
Return False
End If
Catch
MsgBox("You have not select a router!", MsgBoxStyle.Critical)
Return False
End Try


Dim noerror As Boolean = True
Dim i As Integer
For i = 0 To ed.Length - 1
If IsHex(ed.Substring(i, 1)) = False Then
MsgBox("MAC address have to be hexadecimal! (0 - 9 & A - F)", MsgBoxStyle.Critical)
Return False
End If
Next

Return True
End Function

Private Function IsHex(ByVal l As String) As Boolean
Dim table As String = "0123456789ABCDEF"
Dim i As Integer
For i = 0 To table.Length - 1
If l = table.Substring(i, 1) Then
Return True
End If
Next
Return False
End Function


Private Sub Default1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Default1.Click

If IsOkay() = False Then
Exit Sub
End If
Dim regKey As Microsoft.Win32.RegistryKey
Dim Addr As String = GetRoot(combo_network.SelectedItem.ToString())
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Addr, True)

Try
regKey.DeleteValue("NetworkAddress")
Catch
'Do NOTHING
End Try
ShowRestart()

End Sub

Private Sub combo_network_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combo_network.SelectedIndexChanged
End Sub

Private Sub CompNAME_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompName.Click

If TextBox5.Text <> "" Then
Try
Dim sNewName = TextBox5.Text
Dim oShell = CreateObject("WSCript.shell")
Dim sCCS = "HKLM\SYSTEM\CurrentControlSet"
Dim sTcpipParamsRegPath = sCCS & "Services\Tcpip\Parameters"
Dim sCompNameRegPath = sCCS & "Control\ComputerName"

With oShell
.RegDelete(sTcpipParamsRegPath & "Hostname")
.RegDelete(sTcpipParamsRegPath & "NV Hostname")
.RegWrite(sCompNameRegPath & "ComputerName\ComputerName", sNewName)
.RegWrite(sCompNameRegPath & "ActiveComputerName\ComputerName", sNewName)
.RegWrite(sTcpipParamsRegPath & "Hostname", sNewName)
.RegWrite(sTcpipParamsRegPath & "NV Hostname", sNewName)
End With ' oShell
MsgBox("Computer name is changed!")
Catch ex As Exception
MsgBox("Error! Computer name is not changed.")
End Try
Else
MsgBox("Write new computer name!")
End If

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Try
If WebBrowser2.IsBusy = False Then
WebBrowser2.Document.All("12").InvokeMember("Click") '"12" . these are names of button on my router root web site. this wont work for you so you have to set this to be like it is on your router root web site.
Timer2.Enabled = False
MsgBox("Your IP address is changed.")
Me.Text = "IPChanger"
End If
Catch ex As Exception
Timer2.Enabled = False
MsgBox("Error! Try again.")
Me.Text = "IPChanger"
End Try
End Sub

Private Sub ChangeIP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeIP.Click
Try
If WebBrowser2.IsBusy = False Then
Me.Text = "Wait..."
WebBrowser2.Document.All("13").InvokeMember("Click") '"13" . these are names of button on my router root web site. this wont work for you so you have to set this to be like it is on your router root web site.

Timer2.Enabled = True
Else
MsgBox("Wait until web site is ready!")
End If

Catch ex As Exception
MsgBox("Error! Try again.")
End Try

End Sub

Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
Timer7.Stop()
End Sub

Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
TextBox4.CharacterCasing = CharacterCasing.Upper

End Sub

Private Sub mac_text_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mac_text.TextChanged
mac_text.CharacterCasing = CharacterCasing.Upper
End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
TextBox3.CharacterCasing = CharacterCasing.Upper
End Sub
End Class

[/Code]




I know there is some things enabled that are not suppose to be which don't make a difference but I didn't feel like going through the work of removing them just to make this thread. Also I still haven't used some things because im not done with it yet.

I have all the references correct for my codes which is how I used them and saw the suggestions and such. It's suppose to be a MAc and IP address changer. Although the get mac code's end function does not work?

____________________
dirbaio
For future reference, "Responsible disclosure" isn't "acting like a douche about an exploit and demanding compensation".
Level: NaN


Posts: 1210/-1288
EXP: NaN
For next: 0

Since: 07-28-09

From: Spain

Since last post: 10.8 years
Last activity: 9.9 years

Posted on 05-02-11 10:32:18 PM Link
I don't know VB and haven't read your code entirely, but here's some things you should check:

- Some adapters can't change their MAC at all. Make sure yours can, try to change it manually in the driver config and see if it works...
- Are you using vista or 7? If so, are you running your program as admin? Probably non-admin privileges cant change IP and MAC.

(Also, why do people create empty polls? It makes my head hurt so much.)
ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 61/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 05-02-11 11:03:29 PM Link
Originally posted by dirbaio
I don't know VB and haven't read your code entirely, but here's some things you should check:

- Some adapters can't change their MAC at all. Make sure yours can, try to change it manually in the driver config and see if it works...
- Are you using vista or 7? If so, are you running your program as admin? Probably non-admin privileges cant change IP and MAC.

(Also, why do people create empty polls? It makes my head hurt so much.)



Don't post non-useful posts to my topics again please. I just want that sasuke guy or w/e to reply because he is very useful and I think I saw his nick on extreme VB
DigitalBasic
Pancakes!
Level: 174


Posts: 8048/9712
EXP: 70453869
For next: 443998

Since: 07-03-07

Pronouns: they/them

Since last post: 76 days
Last activity: 3 days

Posted on 05-02-11 11:10:09 PM Link
Then why didn't you just PM him instead?

____________________
Taryn

Passed away.

Thanks for being a part of us, even if it wasn't always on the best of terms.

1987-2014


Level: 204


Posts: 13407/14742
EXP: 121753583
For next: 1596235

Since: 09-01-09

From: Seattle

Since last post: 10.1 years
Last activity: 9.8 years

Posted on 05-02-11 11:23:19 PM Link
Originally posted by ShenoxVII
Don't post non-useful posts to my topics again please. I just want that sasuke guy or w/e to reply because he is very useful and I think I saw his nick on extreme VB


Dirbaio is one of Jul's local moderators, you know. You might want to give him more respect than that. He was trying to help. And I'm not sure that you'll get all that much help if you just copy-paste gigantic amounts of code and expect people to wade through it


____________________
TKB Super Mario Bros.TKB Super Mario Bros., Volume II
Lyskar
12210
-The Chaos within trumps the Chaos without-
Level: 192


Posts: 8942/12211
EXP: 99326504
For next: 547067

Since: 07-03-07

From: 52-2-88-7

Since last post: 7.4 years
Last activity: 7.3 years

Posted on 05-02-11 11:27:15 PM Link
Stats
Time/Date
05-02-11 05:27:15 PM
Posts
8942
Days Here
1399
Level
138
Metal_Man88's Post
Your history of bad suggestions to SM64 people, botching VB code and then expecting us to fix it for you, and that double post are putting you on thin ice here, Shenox. Clean your act up before you get thrown out entirely.

____________________

Eisnaught - SSQ² - Mobius Roleplay - SSS
Sukasa

Level: 123


Posts: 3101/4326
EXP: 20936841
For next: 294425

Since: 07-07-07


Since last post: 1.1 years
Last activity: 1.1 years

Posted on 05-02-11 11:34:30 PM Link

Dirbaio's suggestion was definitely not "non-useful." He's right - sometimes you literally cannot change your MAC address.

____________________
Witty Text Here
ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 63/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 05-02-11 11:44:59 PM Link
Originally posted by Metal_Man88
Your history of bad suggestions to SM64 people, botching VB code and then expecting us to fix it for you, and that double post are putting you on thin ice here, Shenox. Clean your act up before you get thrown out entirely.



I'm working with sql references right now. Also I really don't care about what people think of me, this isn't my "more popular" name. I just come on here to get updated with some info. I still have no idea how to pm people on here I could never find it nor had a use for it. I'm bringing my questions to a more suitable forum. I know I probably came across pretty badly, best thing to do is to ignore it so w/e.
ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 64/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 05-03-11 01:03:48 AM Link
Originally posted by dirbaio
I don't know VB and haven't read your code entirely, but here's some things you should check:

- Some adapters can't change their MAC at all. Make sure yours can, try to change it manually in the driver config and see if it works...
- Are you using vista or 7? If so, are you running your program as admin? Probably non-admin privileges cant change IP and MAC.

(Also, why do people create empty polls? It makes my head hurt so much.)



After re-reading what you said I figured another way out around this thanks, someone close this htread and put it in the me4t
Rachel Mae

Creature of Chaos
Level: 141


Posts: 3951/5929
EXP: 33605769
For next: 514245

Since: 07-03-07

Pronouns: she/her
From: Foxglen

Since last post: 21 days
Last activity: 14 hours

Posted on 05-03-11 01:16:05 AM (last edited by Waffle Ryebread at 05-02-11 10:18 PM) Link
Way to completely ignore what MM88 said about double posting.

And no, we're not going to ignore you treating other members like crap, especially when said members are a) staff and b) trying to help. Slip up again and you're history.

____________________
Next newer thread | Next older thread
Jul - Computers and Technology - [VB08] IP / MAC Address change not working? New poll - New thread - Thread closed


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

35 database queries.
Query execution time: 0.129864 seconds
Script execution time: 0.027305 seconds
Total render time: 0.157169 seconds