I have a maxScript that requires to send the mac address of the user to a server and check if it is included in the allowed list.
I have to part fo getting the mac address and the server side is all set.
the only problem is that I want it to be sent by POST so there would be more security to it but I have no idea how to do that.
Asked
Active
Viewed 1,022 times
1

Henjin
- 528
- 2
- 9
- 19
-
The only difference between GET and POST is that with GET the info is in the query string and with POST it is in the body. Edit the question to show how you would do it with GET. – Jerry Jeremiah Aug 01 '18 at 04:28
-
I also have no idea how to do it with get. I used to just send an empty request and have the server get the IP from that and compare it. but because the IP changes alot it is not reliable. – Henjin Aug 01 '18 at 04:30
-
I found this: http://forums.cgsociety.org/showthread.php?f=98&t=1139939 Now I just need to find out how to get the MAC address. – Jerry Jeremiah Aug 01 '18 at 23:52
-
@JerryJeremiah I got the mac here http://forums.cgsociety.org/showthread.php?t=919646 – Henjin Aug 02 '18 at 05:16
1 Answers
2
Okay, I finally figured it out. here is the complete code for getting the mac address and sending it to a server with HttpPost:
--Getting the mac address
NI = dotnetclass "System.Net.NetworkInformation.NetworkInterface";
NI.GetIsNetworkAvailable();
ALL = NI.GetAllNetworkInterfaces();
MACAddress = ALL[1].GetPhysicalAddress();
print (MACAddress.toString());
--Encoding the mac address so it is sendable
A = (dotNetClass "System.Text.Encoding");
PostData = "macaddress=" + MACAddress.toString();
MData = A.ASCII.GetBytes (PostData);
--Creating the Post request
Req = (dotNetClass "System.Net.WebRequest").Create ("http://ip.mdfplan.com/");
Req.Method = "Post";
Req.ContentType = "application/x-www-form-urlencoded";
Req.ContentLength = MData.count;
--Writing the data in the request
S = Req.GetRequestStream();
S.write MData 0 MData.count;
S.close();
--Sending the request and recieving the response
Res = Req.GetResponse();
ResStr = Res.GetResponseStream();
--Reading the respone
objReader = dotnetobject "System.IO.StreamReader" ResStr;
ResText = (objReader.ReadToEnd());

Henjin
- 528
- 2
- 9
- 19