├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── colors.xml │ │ │ ├── drawable │ │ │ │ ├── ic_signal_wifi_4_bar_white_24dp.xml │ │ │ │ ├── ic_vpn_key_white_24dp.xml │ │ │ │ └── ic_signal_wifi_4_bar_lock_white_24dp.xml │ │ │ └── layout │ │ │ │ ├── item_wifi.xml │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── name │ │ │ │ └── caiyao │ │ │ │ └── wifipwd │ │ │ │ ├── base │ │ │ │ ├── BasePresenter.java │ │ │ │ ├── BaseView.java │ │ │ │ └── Common.java │ │ │ │ ├── ui │ │ │ │ ├── MainComponent.java │ │ │ │ ├── MainContract.java │ │ │ │ ├── MainPresenterModule.java │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainPresenter.java │ │ │ │ ├── WifiApplication.java │ │ │ │ ├── data │ │ │ │ ├── Aps.java │ │ │ │ ├── WifiApi.java │ │ │ │ ├── WifiRequest.java │ │ │ │ └── WifiResult.java │ │ │ │ ├── adapter │ │ │ │ └── WifiListAdapter.java │ │ │ │ └── util │ │ │ │ ├── AesUtils.java │ │ │ │ └── WifiUtil.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── name │ │ │ └── caiyao │ │ │ └── wifipwd │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── name │ │ └── caiyao │ │ └── wifipwd │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── WiFiMaster.py ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YiuChoi/WifiPwd/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.base; 2 | 3 | /** 4 | * Created by xiaomu on 2017/4/1. 5 | */ 6 | 7 | public interface BasePresenter { 8 | void start(); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | WifiPwd 3 | wifi_state 4 | NETGEAR 29:23:34:34:34 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.base; 2 | 3 | /** 4 | * Created by xiaomu on 2017/4/1. 5 | */ 6 | 7 | public interface BaseView { 8 | void setPresenter(T presenter); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Apr 01 13:42:47 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/ui/MainComponent.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.ui; 2 | 3 | import dagger.Component; 4 | 5 | /** 6 | * Created by xiaomu on 2017/4/6. 7 | */ 8 | @Component(modules = MainPresenterModule.class) 9 | public interface MainComponent { 10 | void inject(MainActivity activity); 11 | } 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/WifiApplication.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd; 2 | 3 | import android.app.Application; 4 | 5 | import com.orhanobut.logger.Logger; 6 | 7 | /** 8 | * Created by xiaomu on 2017/4/1. 9 | */ 10 | 11 | public class WifiApplication extends Application { 12 | 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | Logger.init(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF9800 4 | #F57C00 5 | #FFE0B2 6 | #4CAF50 7 | #212121 8 | #757575 9 | #BDBDBD 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_signal_wifi_4_bar_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/name/caiyao/wifipwd/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vpn_key_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/ui/MainContract.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.ui; 2 | 3 | import android.net.wifi.ScanResult; 4 | 5 | import java.util.List; 6 | 7 | import name.caiyao.wifipwd.base.BasePresenter; 8 | import name.caiyao.wifipwd.base.BaseView; 9 | 10 | /** 11 | * Created by xiaomu on 2017/4/1. 12 | */ 13 | 14 | public interface MainContract { 15 | 16 | interface View extends BaseView { 17 | 18 | void showWifilist(List list); 19 | 20 | void showPwd(String pwd); 21 | } 22 | 23 | interface Presenter extends BasePresenter { 24 | 25 | void getWifilist(); 26 | 27 | void getPwd(ScanResult scanResult); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_signal_wifi_4_bar_lock_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/ui/MainPresenterModule.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.ui; 2 | 3 | import android.content.Context; 4 | 5 | import dagger.Module; 6 | import dagger.Provides; 7 | 8 | /** 9 | * Created by xiaomu on 2017/4/6. 10 | */ 11 | @Module 12 | public class MainPresenterModule { 13 | private final MainContract.View view; 14 | private final Context context; 15 | 16 | public MainPresenterModule(MainContract.View view, Context context) { 17 | this.view = view; 18 | this.context = context; 19 | } 20 | 21 | @Provides 22 | MainContract.View provideMainContractView() { 23 | return view; 24 | } 25 | 26 | @Provides 27 | Context provideContext(){ 28 | return context; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/data/Aps.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.data; 2 | 3 | /** 4 | * Created by xiaomu on 2017/4/6. 5 | */ 6 | 7 | public class Aps { 8 | String pwd; 9 | String ssid; 10 | String apRefId; 11 | String pwdId; 12 | 13 | public String getPwd() { 14 | return pwd; 15 | } 16 | 17 | public void setPwd(String pwd) { 18 | this.pwd = pwd; 19 | } 20 | 21 | public String getSsid() { 22 | return ssid; 23 | } 24 | 25 | public void setSsid(String ssid) { 26 | this.ssid = ssid; 27 | } 28 | 29 | public String getApRefId() { 30 | return apRefId; 31 | } 32 | 33 | public void setApRefId(String apRefId) { 34 | this.apRefId = apRefId; 35 | } 36 | 37 | public String getPwdId() { 38 | return pwdId; 39 | } 40 | 41 | public void setPwdId(String pwdId) { 42 | this.pwdId = pwdId; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/androidTest/java/name/caiyao/wifipwd/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("name.caiyao.wifipwd", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Sat Apr 01 13:42:50 CST 2017 16 | systemProp.http.proxyHost=127.0.0.1 17 | org.gradle.jvmargs=-Xmx1536m 18 | systemProp.http.proxyPort=1080 19 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/base/Common.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.base; 2 | 3 | /** 4 | * Created by xiaomu on 2017/4/7. 5 | */ 6 | 7 | public class Common { 8 | public static final String AES_KEY="!I50#LSSciCx&q6E"; 9 | public static final String AES_IV="$t%s%12#2b474pXF"; 10 | public static final String DT="{\"origChanId\":\"xiaomi\",\"appId\":\"A0008\",\"ts\":" + 11 | "\"1459936625905\",\"netModel\":\"w\",\"chanId\":\"guanwang\",\"imei\":" + 12 | "\"357541051318147\",\"qid\":\"\",\"mac\":\"e8:92:a4:9b:16:42\",\"capSsid\":" + 13 | "\"hijack\",\"lang\":\"cn\",\"longi\":\"103.985752\",\"nbaps\":\"\",\"capBssid\":" + 14 | "\"b0:d5:9d:45:b9:85\",\"bssid\":\"MAC\",\"mapSP\":\"t\"," + 15 | "\"userToken\":\"\",\"verName\":\"4.1.8\",\"ssid\":\"SSID\"," + 16 | "\"verCode\":\"3028\",\"uhid\":\"a0000000000000000000000000000001\"," + 17 | "\"lati\":\"30.579577\",\"dhid\":\"9374df1b6a3c4072a0271d52cbb2c7b6\"}"; 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/data/WifiApi.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.data; 2 | 3 | import io.reactivex.Observable; 4 | import retrofit2.http.Field; 5 | import retrofit2.http.FormUrlEncoded; 6 | import retrofit2.http.POST; 7 | 8 | /** 9 | * Created by xiaomu on 2017/4/6. 10 | */ 11 | 12 | public interface WifiApi { 13 | 14 | @FormUrlEncoded 15 | @POST("http://ap.51y5.net/ap/fa.sec") 16 | Observable getPwd(@Field("appId") String appId, @Field("pid") String pid, 17 | @Field("ed") String ed, @Field("st") String st, @Field("et") String et, 18 | @Field("sign") String sign); 19 | 20 | @FormUrlEncoded 21 | @POST("http://wifiapi02.51y5.net/wifiapi/fa.cmd") 22 | Observable getDhid(@Field("appId") String appId, @Field("pid") String pid, 23 | @Field("ed") String ed, @Field("st") String st, @Field("et") String et, 24 | @Field("sign") String sign); 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\sdk\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_wifi.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | 17 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/data/WifiRequest.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.data; 2 | 3 | import okhttp3.OkHttpClient; 4 | import okhttp3.logging.HttpLoggingInterceptor; 5 | import retrofit2.Retrofit; 6 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 7 | import retrofit2.converter.gson.GsonConverterFactory; 8 | 9 | /** 10 | * Created by xiaomu on 2017/4/6. 11 | */ 12 | 13 | public class WifiRequest { 14 | 15 | private static WifiApi wifiApi = null; 16 | 17 | 18 | public static WifiApi getWifiApi() { 19 | synchronized (WifiRequest.class) { 20 | if (wifiApi == null) { 21 | wifiApi = new Retrofit.Builder() 22 | .baseUrl("http://www.google.com") 23 | .client(new OkHttpClient().newBuilder().addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build()) 24 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 25 | .addConverterFactory(GsonConverterFactory.create()) 26 | .build().create(WifiApi.class); 27 | } 28 | return wifiApi; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/data/WifiResult.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.data; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by xiaomu on 2017/4/6. 7 | */ 8 | 9 | public class WifiResult { 10 | String qid; 11 | String sysTime; 12 | String retCd; 13 | String topn; 14 | String s; 15 | ArrayList aps; 16 | 17 | public String getQid() { 18 | return qid; 19 | } 20 | 21 | public void setQid(String qid) { 22 | this.qid = qid; 23 | } 24 | 25 | public String getSysTime() { 26 | return sysTime; 27 | } 28 | 29 | public void setSysTime(String sysTime) { 30 | this.sysTime = sysTime; 31 | } 32 | 33 | public String getRetCd() { 34 | return retCd; 35 | } 36 | 37 | public void setRetCd(String retCd) { 38 | this.retCd = retCd; 39 | } 40 | 41 | public String getTopn() { 42 | return topn; 43 | } 44 | 45 | public void setTopn(String topn) { 46 | this.topn = topn; 47 | } 48 | 49 | public String getS() { 50 | return s; 51 | } 52 | 53 | public void setS(String s) { 54 | this.s = s; 55 | } 56 | 57 | public ArrayList getAps() { 58 | return aps; 59 | } 60 | 61 | public void setAps(ArrayList aps) { 62 | this.aps = aps; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 20 | 21 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "name.caiyao.wifipwd" 8 | minSdkVersion 14 9 | targetSdkVersion 21 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testCompile 'junit:junit:4.12' 30 | compile 'com.orhanobut:logger:1.15' 31 | compile 'com.jakewharton:butterknife:8.5.1' 32 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 33 | compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 34 | compile 'io.reactivex.rxjava2:rxjava:2.0.1' 35 | compile 'com.github.hotchemi:permissionsdispatcher:2.3.2' 36 | annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.2' 37 | compile 'com.squareup.retrofit2:retrofit:2.2.0' 38 | compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0' 39 | compile 'com.squareup.retrofit2:converter-gson:2.2.0' 40 | compile 'com.squareup.okhttp3:logging-interceptor:3.6.0' 41 | compile 'com.google.dagger:dagger:2.10' 42 | annotationProcessor 'com.google.dagger:dagger-compiler:2.10' 43 | compile 'com.airbnb.android:lottie:2.0.0-beta3' 44 | compile 'com.android.support:recyclerview-v7:25.3.1' 45 | compile 'com.google.code.gson:gson:2.8.0' 46 | } 47 | -------------------------------------------------------------------------------- /WiFiMaster.py: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | # Author: Zke1ev3n@outlook.com 3 | 4 | import collections 5 | import hashlib 6 | import json 7 | import sys 8 | import urllib 9 | import urllib2 10 | 11 | from Crypto.Cipher import AES 12 | 13 | 14 | def getMd5(str): 15 | md5 = hashlib.md5() 16 | md5.update(str) 17 | return md5.hexdigest() 18 | 19 | dt = collections.OrderedDict() 20 | dt['origChanId'] = 'xiaomi' 21 | dt['appId'] = 'A0008' 22 | dt['ts'] = '1459936625905' 23 | dt['netModel'] = 'w' 24 | dt['chanId'] = 'guanwang' 25 | dt['imei'] = '357541051318147' 26 | dt['qid'] = '' 27 | dt['mac'] = 'e8:92:a4:9b:16:42' 28 | dt['capSsid'] = 'hijack' 29 | dt['lang'] = 'cn' 30 | dt['longi'] = '103.985752' 31 | dt['nbaps'] = '' 32 | dt['capBssid'] = 'b0:d5:9d:45:b9:85' 33 | dt['bssid'] = '20:4e:7f:39:4d:9f' 34 | dt['mapSP'] = 't' 35 | dt['userToken'] = '' 36 | dt['verName'] = '4.1.8' 37 | dt['ssid'] = 'NETGEAR' 38 | dt['verCode'] = '3028' 39 | dt['uhid'] = 'a0000000000000000000000000000001' 40 | dt['lati'] = '30.579577' 41 | dt['dhid'] = '9374df1b6a3c4072a0271d52cbb2c7b6' 42 | dt = json.dumps(dt,ensure_ascii=False,separators=(',',':')) 43 | print dt 44 | dt = urllib.quote(dt) 45 | j = len(dt) 46 | i = 0 47 | while(i < 16 - j % 16): 48 | dt = dt + ' ' 49 | i = i + 1 50 | cipher = AES.new(b"!I50#LSSciCx&q6E", AES.MODE_CBC, b"$t%s%12#2b474pXF") 51 | ed = cipher.encrypt(dt).encode('hex').upper() 52 | data = {} 53 | data['appId'] = 'A0008' 54 | data['pid'] = '00300109' 55 | data['ed'] = ed 56 | data['st'] = 'm' 57 | data['et'] = 'a' 58 | ss = "" 59 | for key in sorted(data): 60 | ss = ss + data[key] 61 | salt = '*Lm%qiOHVEedH3%A^uFFsZvFH9T8QAZe' 62 | sign = getMd5(ss+salt) 63 | data['sign'] = sign 64 | print data 65 | url = 'http://ap.51y5.net/ap/fa.sec' 66 | post_data = urllib.urlencode(data) 67 | req = urllib2.urlopen(url, post_data) 68 | content = req.read() 69 | result = json.loads(content.decode('utf-8')) 70 | print result 71 | if len(result['aps']) == 0: 72 | print "Not Found" 73 | sys.exit() 74 | epwd = result['aps'][0]['pwd'] 75 | cipher = AES.new(b"!I50#LSSciCx&q6E", AES.MODE_CBC, b"$t%s%12#2b474pXF") 76 | pdd = cipher.decrypt(epwd.decode("hex")) 77 | length = int(pdd[:3]) 78 | pwd = pdd[3:][:length] 79 | print "password is: " + pwd 80 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/ui/MainActivity.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.ui; 2 | 3 | import android.net.wifi.ScanResult; 4 | import android.os.Bundle; 5 | import android.support.v4.widget.SwipeRefreshLayout; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.View; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | import javax.inject.Inject; 15 | 16 | import butterknife.BindView; 17 | import butterknife.ButterKnife; 18 | import name.caiyao.wifipwd.R; 19 | import name.caiyao.wifipwd.adapter.WifiListAdapter; 20 | 21 | public class MainActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener, MainContract.View { 22 | 23 | @BindView(R.id.rv_wifi) 24 | RecyclerView rv_wifi; 25 | 26 | @BindView(R.id.srl_wifi) 27 | SwipeRefreshLayout srl_wifi; 28 | 29 | @Inject 30 | MainPresenter mainPresenter; 31 | 32 | List scanResults = new ArrayList<>(); 33 | 34 | WifiListAdapter wifiListAdapter; 35 | 36 | @Override 37 | protected void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_main); 40 | ButterKnife.bind(this); 41 | 42 | LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); 43 | rv_wifi.setLayoutManager(linearLayoutManager); 44 | rv_wifi.setHasFixedSize(true); 45 | srl_wifi.setOnRefreshListener(this); 46 | 47 | DaggerMainComponent.builder().mainPresenterModule(new MainPresenterModule(this, this)).build().inject(this); 48 | wifiListAdapter = new WifiListAdapter(scanResults); 49 | rv_wifi.setAdapter(wifiListAdapter); 50 | wifiListAdapter.setOnItemCLickListener(new WifiListAdapter.OnItemCLickListener() { 51 | @Override 52 | public void OnItemClick(View view, int position) { 53 | mainPresenter.getPwd(scanResults.get(position)); 54 | } 55 | }); 56 | mainPresenter.getWifilist(); 57 | } 58 | 59 | @Override 60 | public void onRefresh() { 61 | mainPresenter.getWifilist(); 62 | } 63 | 64 | @Override 65 | public void setPresenter(MainContract.Presenter presenter) { 66 | mainPresenter = (MainPresenter) presenter; 67 | } 68 | 69 | @Override 70 | public void showWifilist(List list) { 71 | this.scanResults.clear(); 72 | this.scanResults.addAll(list); 73 | wifiListAdapter.notifyDataSetChanged(); 74 | srl_wifi.setRefreshing(false); 75 | } 76 | 77 | @Override 78 | public void showPwd(String pwd) { 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/adapter/WifiListAdapter.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.adapter; 2 | 3 | import android.net.wifi.ScanResult; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import java.util.List; 12 | 13 | import butterknife.BindView; 14 | import butterknife.ButterKnife; 15 | import name.caiyao.wifipwd.R; 16 | 17 | /** 18 | * Created by xiaomu on 2017/4/1. 19 | */ 20 | 21 | public class WifiListAdapter extends RecyclerView.Adapter implements View.OnClickListener { 22 | 23 | private List scanResults; 24 | 25 | public interface OnItemCLickListener { 26 | void OnItemClick(View view, int position); 27 | } 28 | 29 | private OnItemCLickListener onItemCLickListener; 30 | 31 | public WifiListAdapter(List scanResults) { 32 | this.scanResults = scanResults; 33 | } 34 | 35 | @Override 36 | public WifiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 37 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_wifi, parent, false); 38 | view.setOnClickListener(this); 39 | return new WifiViewHolder(view); 40 | } 41 | 42 | 43 | public void setOnItemCLickListener(OnItemCLickListener onItemCLickListener){ 44 | this.onItemCLickListener = onItemCLickListener; 45 | } 46 | 47 | @Override 48 | public void onClick(View v) { 49 | if (onItemCLickListener == null) { 50 | throw new NullPointerException("onItemCLickListener is null"); 51 | } 52 | onItemCLickListener.OnItemClick(v, (Integer) v.getTag()); 53 | } 54 | 55 | @Override 56 | public void onBindViewHolder(WifiViewHolder holder, int position) { 57 | ScanResult scanResult = scanResults.get(position); 58 | if (scanResult.capabilities.contains("WPA")) { 59 | holder.wifi_state.setImageResource(R.drawable.ic_signal_wifi_4_bar_lock_white_24dp); 60 | } else { 61 | holder.wifi_state.setImageResource(R.drawable.ic_signal_wifi_4_bar_white_24dp); 62 | } 63 | holder.wifi_ssid.setText(scanResult.SSID + "\n" + scanResult.BSSID); 64 | holder.itemView.setTag(position); 65 | } 66 | 67 | @Override 68 | public int getItemCount() { 69 | return scanResults.size(); 70 | } 71 | 72 | class WifiViewHolder extends RecyclerView.ViewHolder { 73 | @BindView(R.id.wifi_ssid) 74 | TextView wifi_ssid; 75 | 76 | @BindView(R.id.wifi_state) 77 | ImageView wifi_state; 78 | 79 | WifiViewHolder(View itemView) { 80 | super(itemView); 81 | ButterKnife.bind(this, itemView); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/ui/MainPresenter.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.ui; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.net.wifi.ScanResult; 6 | import android.os.Build; 7 | 8 | import com.orhanobut.logger.Logger; 9 | 10 | import java.io.UnsupportedEncodingException; 11 | import java.net.URLEncoder; 12 | 13 | import javax.inject.Inject; 14 | 15 | import io.reactivex.Observer; 16 | import io.reactivex.android.schedulers.AndroidSchedulers; 17 | import io.reactivex.disposables.Disposable; 18 | import io.reactivex.schedulers.Schedulers; 19 | import name.caiyao.wifipwd.data.WifiRequest; 20 | import name.caiyao.wifipwd.data.WifiResult; 21 | import name.caiyao.wifipwd.util.AesUtils; 22 | import name.caiyao.wifipwd.util.WifiUtil; 23 | 24 | import static name.caiyao.wifipwd.base.Common.AES_IV; 25 | import static name.caiyao.wifipwd.base.Common.AES_KEY; 26 | import static name.caiyao.wifipwd.base.Common.DT; 27 | 28 | /** 29 | * Created by xiaomu on 2017/4/6. 30 | */ 31 | 32 | public class MainPresenter implements MainContract.Presenter { 33 | 34 | private Context context; 35 | 36 | private final MainContract.View view; 37 | 38 | @Inject 39 | MainPresenter(Context context, MainContract.View view) { 40 | this.view = view; 41 | this.context = context; 42 | } 43 | 44 | @Inject 45 | void setupListeners() { 46 | view.setPresenter(this); 47 | } 48 | 49 | @Override 50 | public void start() { 51 | 52 | } 53 | 54 | @Override 55 | public void getWifilist() { 56 | WifiUtil wifiUtil = new WifiUtil(context); 57 | wifiUtil.startScan(); 58 | view.showWifilist(wifiUtil.getWifiList()); 59 | } 60 | 61 | @TargetApi(Build.VERSION_CODES.KITKAT) 62 | @Override 63 | public void getPwd(ScanResult scanResult) { 64 | String s = null; 65 | try { 66 | s = URLEncoder.encode(DT.replace("SSID", scanResult.SSID).replace("MAC", scanResult.BSSID), "UTF-8"); 67 | } catch (UnsupportedEncodingException e) { 68 | e.printStackTrace(); 69 | } 70 | String appId = "A0008"; 71 | String ed = AesUtils.encryptString(AES_KEY, s, AES_IV); 72 | String et = "a"; 73 | String pid = "00300109"; 74 | String st = "m"; 75 | String ss = appId + ed + et + pid + st; 76 | String salt = "*Lm%qiOHVEedH3%A^uFFsZvFH9T8QAZe"; 77 | String sign = AesUtils.getMD5(ss + salt); 78 | WifiRequest.getWifiApi() 79 | .getPwd(appId, pid, ed, st, et, sign) 80 | .subscribeOn(Schedulers.io()) 81 | .observeOn(AndroidSchedulers.mainThread()) 82 | .subscribe(new Observer() { 83 | @Override 84 | public void onSubscribe(Disposable d) { 85 | 86 | } 87 | 88 | @Override 89 | public void onNext(WifiResult value) { 90 | if (!value.getAps().isEmpty()) { 91 | String pdd = AesUtils.decryptString(AES_KEY, value.getAps().get(0).getPwd(), AES_IV); 92 | if (pdd != null) { 93 | Logger.i(pdd); 94 | int length = Integer.parseInt(pdd.substring(0, 3)); 95 | String pwd = pdd.substring(3, 3 + length); 96 | Logger.i(pwd); 97 | view.showPwd(pwd); 98 | } 99 | } 100 | } 101 | 102 | @Override 103 | public void onError(Throwable e) { 104 | 105 | } 106 | 107 | @Override 108 | public void onComplete() { 109 | 110 | } 111 | }); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/util/AesUtils.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.InvalidAlgorithmParameterException; 5 | import java.security.InvalidKeyException; 6 | import java.security.MessageDigest; 7 | import java.security.NoSuchAlgorithmException; 8 | 9 | import javax.crypto.BadPaddingException; 10 | import javax.crypto.Cipher; 11 | import javax.crypto.IllegalBlockSizeException; 12 | import javax.crypto.NoSuchPaddingException; 13 | import javax.crypto.spec.IvParameterSpec; 14 | import javax.crypto.spec.SecretKeySpec; 15 | 16 | public class AesUtils { 17 | 18 | public static String encryptString(String key, String s, String iv) { 19 | try { 20 | SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); 21 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); 22 | IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes()); 23 | cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec); 24 | byte[] encrypted = cipher.doFinal(s.getBytes()); 25 | return parseByte2HexStr(encrypted); 26 | } catch (UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidAlgorithmParameterException e) { 27 | e.printStackTrace(); 28 | } 29 | return null; 30 | } 31 | 32 | private static String parseByte2HexStr(byte buf[]) { 33 | StringBuilder sb = new StringBuilder(); 34 | for (byte aBuf : buf) { 35 | String hex = Integer.toHexString(aBuf & 0xFF); 36 | if (hex.length() == 1) { 37 | hex = '0' + hex; 38 | } 39 | sb.append(hex.toUpperCase()); 40 | } 41 | return sb.toString(); 42 | } 43 | 44 | private static byte[] parseHexStr2Byte(String hexStr) { 45 | if (hexStr.length() < 1) { 46 | return null; 47 | } 48 | byte[] result = new byte[hexStr.length() / 2]; 49 | for (int i = 0; i < hexStr.length() / 2; i++) { 50 | int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16); 51 | int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16); 52 | result[i] = (byte) (high * 16 + low); 53 | } 54 | return result; 55 | } 56 | 57 | public static String decryptString(String key, String s, String iv) { 58 | try { 59 | SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES"); 60 | Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); 61 | IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes()); 62 | cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec); 63 | byte[] decrypted = cipher.doFinal(parseHexStr2Byte(s)); 64 | return new String(decrypted); 65 | } catch (UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | BadPaddingException | IllegalBlockSizeException | InvalidAlgorithmParameterException e) { 66 | e.printStackTrace(); 67 | } 68 | return null; 69 | } 70 | 71 | /** 72 | * 对字符串md5加密 73 | * 74 | * @param str 75 | * @return 76 | */ 77 | public static String getMD5(String str) { 78 | try { 79 | // 生成一个MD5加密计算摘要 80 | MessageDigest md = MessageDigest.getInstance("MD5"); 81 | // 计算md5函数 82 | md.update(str.getBytes()); 83 | byte b[] = md.digest(); 84 | int i; 85 | StringBuilder buf = new StringBuilder(""); 86 | for (byte aB : b) { 87 | i = aB; 88 | if (i < 0) { 89 | i += 256; 90 | } 91 | if (i < 16) { 92 | buf.append("0"); 93 | } 94 | buf.append(Integer.toHexString(i)); 95 | } 96 | //32位加密 97 | return buf.toString(); 98 | } catch (Exception e) { 99 | e.printStackTrace(); 100 | } 101 | return null; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/src/main/java/name/caiyao/wifipwd/util/WifiUtil.java: -------------------------------------------------------------------------------- 1 | package name.caiyao.wifipwd.util; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.net.wifi.ScanResult; 6 | import android.net.wifi.WifiConfiguration; 7 | import android.net.wifi.WifiInfo; 8 | import android.net.wifi.WifiManager; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Created by xiaomu on 2017/4/1. 14 | */ 15 | public class WifiUtil { 16 | // 定义WifiManager对象 17 | private WifiManager mWifiManager; 18 | // 定义WifiInfo对象 19 | private WifiInfo mWifiInfo; 20 | // 扫描出的网络连接列表 21 | private List mWifiList; 22 | // 网络连接列表 23 | private List mWifiConfiguration; 24 | // 定义一个WifiLock 25 | WifiManager.WifiLock mWifiLock; 26 | 27 | public WifiUtil(Context context) { 28 | mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); 29 | mWifiInfo = mWifiManager.getConnectionInfo(); 30 | 31 | } 32 | 33 | // 打开WIFI 34 | public void openWifi() { 35 | if (!mWifiManager.isWifiEnabled()) { 36 | mWifiManager.setWifiEnabled(true); 37 | } 38 | } 39 | 40 | // 关闭WIFI 41 | public void closeWifi() { 42 | if (mWifiManager.isWifiEnabled()) { 43 | mWifiManager.setWifiEnabled(false); 44 | } 45 | } 46 | 47 | //获取WIFI状态 48 | public int getWifiState(){ 49 | return mWifiManager.getWifiState(); 50 | } 51 | // 锁定WifiLock 52 | public void acquireWifiLock() { 53 | mWifiLock.acquire(); 54 | } 55 | 56 | // 解锁WifiLock 57 | public void releaseWifiLock() { 58 | // 判断时候锁定 59 | if (mWifiLock.isHeld()) { 60 | mWifiLock.acquire(); 61 | } 62 | } 63 | 64 | // 创建一个WifiLock 65 | public void creatWifiLock() { 66 | mWifiLock = mWifiManager.createWifiLock("Test"); 67 | } 68 | 69 | // 得到配置好的网络 70 | public List getConfiguration() { 71 | return mWifiConfiguration; 72 | } 73 | 74 | // 指定配置好的网络进行连接 75 | public void connectConfiguration(int index) { 76 | // 索引大于配置好的网络索引返回 77 | if (index > mWifiConfiguration.size()) { 78 | return; 79 | } 80 | // 连接配置好的指定ID的网络 81 | mWifiManager.enableNetwork(mWifiConfiguration.get(index).networkId, 82 | true); 83 | } 84 | 85 | public void startScan() { 86 | mWifiManager.startScan(); 87 | // 得到扫描结果 88 | mWifiList = mWifiManager.getScanResults(); 89 | // 得到配置好的网络连接 90 | mWifiConfiguration = mWifiManager.getConfiguredNetworks(); 91 | 92 | } 93 | 94 | // 得到网络列表 95 | public List getWifiList() { 96 | return mWifiList; 97 | } 98 | 99 | // 查看扫描结果 100 | public StringBuilder lookUpScan() { 101 | StringBuilder stringBuilder = new StringBuilder(); 102 | for (int i = 0; i < mWifiList.size(); i++) { 103 | stringBuilder.append("Index_").append(Integer.valueOf(i + 1).toString()).append(":"); 104 | // 将ScanResult信息转换成一个字符串包 105 | // 其中把包括:BSSID、SSID、capabilities、frequency、level 106 | stringBuilder.append((mWifiList.get(i)).toString()); 107 | stringBuilder.append("/n"); 108 | } 109 | return stringBuilder; 110 | } 111 | 112 | // 得到MAC地址 113 | @SuppressLint("HardwareIds") 114 | public String getMacAddress() { 115 | return (mWifiInfo == null) ? "NULL" : mWifiInfo.getMacAddress(); 116 | } 117 | 118 | // 得到接入点的BSSID 119 | public String getBSSID() { 120 | return (mWifiInfo == null) ? "NULL" : mWifiInfo.getBSSID(); 121 | } 122 | 123 | // 得到IP地址 124 | public int getIPAddress() { 125 | return (mWifiInfo == null) ? 0 : mWifiInfo.getIpAddress(); 126 | } 127 | 128 | // 得到连接的ID 129 | public int getNetworkId() { 130 | return (mWifiInfo == null) ? 0 : mWifiInfo.getNetworkId(); 131 | } 132 | 133 | // 得到WifiInfo的所有信息包 134 | public String getWifiInfo() { 135 | return (mWifiInfo == null) ? "NULL" : mWifiInfo.toString(); 136 | } 137 | 138 | // 添加一个网络并连接 139 | public void addNetwork(WifiConfiguration wcg) { 140 | int wcgID = mWifiManager.addNetwork(wcg); 141 | mWifiManager.enableNetwork(wcgID, true); 142 | } 143 | 144 | // 断开指定ID的网络 145 | public void disconnectWifi(int netId) { 146 | mWifiManager.disableNetwork(netId); 147 | mWifiManager.disconnect(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | --------------------------------------------------------------------------------