![]() |
|
[.NET] [Source] iCloud Login Example[VB.NET] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [Source] iCloud Login Example[VB.NET] (/showthread.php?tid=4982101) |
[Source] iCloud Login Example[VB.NET] - Judicious⭐️ - Sep 9, 2015 I'm working on a special project and I thought I would share some code with you guys. As far as I know this is not available anywhere else in visual basic. This is just the core login and I do not intend to go into the icloud protocol or basic encryption at this time. I'm sure some of you might find this useful so I figured I would share it with the community for a limited time. I say a "limited time" because I do NOT intend on having this posted for too long for obvious reasons. I'm not a self entitled "master coder" by any means so criticizing my code with over analysis is going to get you no where. Please refrain from posting pointless replies fueled by your internet ego and filled with flames. If you wish to simplify the code a bit let me know via pm and I will add your suggestions with credit. Note: This is the login method used to retrieve backups from the cloud. A great deal of documentation regarding icloud helped me in making this code. That specific documentation can be found here: https://code.google.com/p/iphone-dataprotection/ I will be building on this source as time passes. Now let's get into it. If you just want to view the full code you can do so right here: Full Code (Click to View) 'Imports: Code Imports System.IO'We set these variables for usage: Code Dim auth As String, dsPrsID As String, mmeAuthToken As String, postData As String, CLIENT_INFO As String'Setting the Client Info string: Code CLIENT_INFO = "<iPhone2,1> <iPhone OS;5.1.1;9B206> <com.apple.AppleAccount/1.0 ((null)/(null))>"'Encoding the login creds to bytes: Code ibyt = System.Text.Encoding.UTF8.GetBytes("[email protected]" & ":" & "Password")'Setting the auth string and converting the bytes to an encrytped Base64 string: Code auth = "Basic " & System.Convert.ToBase64String(ibyt)'This is the request URL: Code request = WebRequest.Create("https://setup.icloud.com/setup/authenticate/$APPLE_ID$")'This is the method for the request: Code request.Method = "POST"'We're gonna set the postdata to nothing and then convert it to bytes. I did this to build on it in the future if needed. Rather than just setting the byte to nothing. Code postData = ""'Setting the Header for authorization: Code request.Headers.Set("Authorization", auth)'DataStreams and writing our post data: Code dataStream = request.GetRequestStream()'Using Try so we can catch errors and display feedback for invalid logins, etc. Code Try'Getting our response and saving it as a string: Code Response = request.GetResponse()'Looking for a specific key for a successful login. Code If InStr(responseFromServer, "AccountInfo") Then'Parsing response to get the dsPrsID: Code dsPrsID = Split(responseFromServer, "dsPrsID</key>")(1)'Parsing response to get mmeAuthToken Code mmeAuthToken = Split(responseFromServer, "mmeAuthToken</key>")(1)'Displaying a message box on successful login and ending the IF Code MsgBox("Login Successful." & vbCrLf & vbCrLf & "dsPrsID = " & dsPrsID & vbCrLf & "mmeAuthToken = " & mmeAuthToken)'Close Connections/Streams Code reader.Close() : dataStream.Close() : Response.Close()'This is where we handle the errors. Code Catch ex As Exception |