Getting iPhone UDID and IMEI from Mobile Safari Using a Java Servlet

I want to get iPhone UDID through Mobile Safari. I use .mobileconifg as

<plist version="1.0"> <dict> <key>PayloadContent</key> <dict> <key>URL</key> <string>http://192.168.12.45:8080/enroll/retrieve</string> <key>DeviceAttributes</key> <array> <string>UDID</string> <string>SERIAL</string> <string>CHALLENGE</string> <string>IMEI</string> <string>ICCID</string> <string>VERSION</string> <string>PRODUCT</string> <string>DEVICE_NAME</string> <string>MAC_ADDRESS_EN0</string> </array> </dict> <key>PayloadOrganization</key> <string>Org</string> <key>PayloadDisplayName</key> <string>Profile Service</string> <key>PayloadVersion</key> <integer>1</integer> <key>PayloadUUID</key> <string>D6F1B2A3-0039-48B5-915B-8E2B35663816</string> <key>PayloadIdentifier</key> <string>Identifer</string> <key>PayloadDescription</key> <string>This temporary profile will be used to find and display your current device UDID.</string> <key>PayloadType</key> <string>Profile Service</string> </dict> </plist> 

retrieve.php

 <?php $data = file_get_contents('php://input'); header('Location: http://192.168.12.45/enroll/info?'.$data, true, 301); ?> 

info is a directory, not a page, I created index.php in this directory. I get data in $ _GET.

But I can get from php.

But I want to use the Java servlet, I changed the url in the mobileconfig file to the servlet url, but I cannot get any values ​​in java.

get java code

  Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String paramName = (String) headerNames.nextElement(); String paramValue = request.getHeader(paramName); System.out.println("paramValue :" + paramValue); } 

Output:

 paramValue :192.168.12.45:8080 paramValue :keep-alive paramValue :gzip, deflate paramValue :Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D201 Safari/9537.53 paramValue :en-us paramValue :text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 

it shows an error like this

enter image description here

But I want a Java servlet to get IMEI. I want to change the above PHP code to a Java servlet. How to solve this problem and set a profile to get UDID and IMEI

+6
source share
2 answers

Perhaps this is because encryption is enabled in your database file or in the directory containing it. Using:

NSFileManager setAttributes:ofItemAtPath:error: with NSFileProtectionNone

+3
source

So you want to use the Java servlet instead of PHP. According to this article , this may not work, as it seems that the recipient URL specified in your .mobileconfig file should be a PHP file:

QUIRK WARNING: For some reason, this process is extremely different from how your server responds when it sends a user to your predefined URL. After many attempts, I believe your receiving URL MUST be a .php file. It sounds nuts, but I'm serious.

But you could still try. According to this post , this Java code should be roughly equivalent to PHP php://input , this is in your servlet:

  InputStream stream = request.getInputStream(); byte[] buffer = new byte[512]; StringBuilder builder = new StringBuilder(); while (stream.read(buffer) != -1) { builder.append(new String(buffer)); } System.out.println(builder); 

If this still doesn't work, I suppose you have no choice but to do what the author of the article did, and use PHP only to redirect to the servlet. In this case, it would be better if in retrieve.php , you need to pass $data as a named query parameter by changing '/info?'.$data to '/info?data='.$data , for example:

 <?php $data = file_get_contents('php://input'); header('Location: http://192.168.12.45/enroll/info?data='.rawurlencode($data)); ?> 

I also wrapped $data in rawurlencode($data) and removed additional parameters that don't seem necessary.

Then in your servlet you can access the data parameter as follows:

 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String data = request.getParameter("data"); System.out.println(data); } 
0
source

Source: https://habr.com/ru/post/979454/


All Articles