Viber Communication Security - Bad Request
Viber Communication Security - Bad Request
Viber Communication Security - Bad Request
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Experiments Chapter 3<br />
1 String GetDeviceUDID ( Context paramContext )<br />
2 {<br />
3 log (" GetDeviceUDID ");<br />
4 SharedPreferences localSharedPreferences = PreferenceManager .<br />
getDefaultSharedPreferences ( paramContext );<br />
5 Object localObject = localSharedPreferences . getString (" viber_udid ", "");<br />
6 log (" UDID ␣in␣ preferences :" + ( String ) localObject );<br />
7 if ((( String ) localObject ). equals (""))<br />
8 {<br />
9 log (" UDID ␣ not ␣ found ␣in␣ preferences ,␣ generate ");<br />
10 String str1 = (( TelephonyManager ) paramContext . getSystemService (" phone ")).<br />
getDeviceId ();<br />
11 if (( TextUtils . isEmpty ( str1 )) || ( str1 == null ))<br />
12 {<br />
13 SecureRandom localSecureRandom = new SecureRandom ();<br />
14 str1 = localSecureRandom . nextLong () + localSecureRandom . nextLong ();<br />
15 }<br />
16 try<br />
17 {<br />
18 String str2 = Convert . getSha1 ( str1 );<br />
19 localObject = str2 ;<br />
20 if (! Patterns . UDID . matcher (( CharSequence ) localObject ). matches ())<br />
21 throw new IllegalStateException (" error ␣ generating ␣ UDID ␣-␣ pattern ␣ doesn ’t␣<br />
match !");<br />
22 }<br />
23 catch ( NoSuchAlgorithmException localNoSuchAlgorithmException )<br />
24 {<br />
25 throw new IllegalStateException (" error ␣ generating ␣ UDID ");<br />
26 }<br />
27 localSharedPreferences . edit (). putString (" viber_udid ", ( String ) localObject ).<br />
commit ();<br />
28 }<br />
29 log (" UDID ␣is␣" + ( String ) localObject );<br />
30 return ( String ) localObject ;<br />
31 }<br />
Listing 3: Method GetDeviceUDID in class<br />
com.viber.voip.registration.HardwareParametersImpl<br />
This above piece of code is actually responsible for the generation of an Unique Device Identifier<br />
(udid) . Basically, it first looks in the corresponding locally stored configuration file of <strong>Viber</strong> to see<br />
if a udid is already established. If it is, it simply returns the udid as a string. Otherwise, it calls the<br />
getDeviceId method in the Android framework and stores the result in the str1 variable. Normally<br />
the getDeviceId method returns the International Mobile Equipment Identity (imei) number (for<br />
Global System for Mobile <strong>Communication</strong>s (gsm) -based Android devices).[36]<br />
If it does not return anything, a “a pseudo-random uniformly distributed long” is generated by the<br />
method nextLong of the SecureRandom class and stored in the str1 variable.[37] The content of the<br />
str1 variable (either the imei or random number) is then hashed with Secure Hash Algorithm (sha) -<br />
1. The resulting hash is stored in the str2 variable and compared to a pattern to verify its format<br />
is correct. The code of this pattern is shown in listing 4.<br />
28