Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lionche committed Nov 21, 2020
0 parents commit 4fb054e
Show file tree
Hide file tree
Showing 43 changed files with 1,120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'com.android.application'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"

defaultConfig {
applicationId "com.example.mynet"
minSdkVersion 22
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.14.1'


}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.mynet;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.mynet", appContext.getPackageName());
}
}
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mynet">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>




<application

android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/allow_http"
android:theme="@style/Theme.MyNet"
tools:targetApi="n">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
53 changes: 53 additions & 0 deletions app/src/main/java/com/example/mynet/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.example.mynet;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import static com.example.mynet.SendPost.getInfo;
import static com.example.mynet.SendPost.passwordPost;
import static com.example.mynet.utils.GetAddress.getIpAddress;
import static com.example.mynet.utils.GetAddress.getMacAddressFromIp;

public class MainActivity extends AppCompatActivity {

private EditText et_password;
private EditText et_name;
private Button bt_login;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et_name = findViewById(R.id.et_name);
et_password = findViewById(R.id.et_password);
bt_login = findViewById(R.id.bt_login);

String ipadr = getIpAddress(this);
String macadr = getMacAddressFromIp(this);




bt_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String name = et_name.getText().toString();
String password = et_password.getText().toString();

Log.d("testhttp",name+" "+password);
getInfo(name,password,ipadr,macadr);
SendPost.LoginPost();
}
});


}

}
73 changes: 73 additions & 0 deletions app/src/main/java/com/example/mynet/SendPost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.example.mynet;

import android.content.Context;
import android.util.Log;

import java.io.IOException;

import okhttp3.*;

import static com.example.mynet.utils.GetAddress.getIpAddress;
import static com.example.mynet.utils.GetAddress.getMacAddressFromIp;

public class SendPost {
static String TAG = "testhttp";
static String namePost = null;
static String passwordPost = null;
static String ipPost = null;
static String macPost = null;

public static void getInfo(String name,String password,String ip ,String mac){
namePost = name;
passwordPost = password;
ipPost = ip;
macPost = mac;
}



public static void LoginPost(){

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
// RequestBody body = RequestBody.create(mediaType, "{\"deviceType\":\"PC\",\"webAuthUser\":\"202032908\",\"webAuthPassword\":\"09005X\",\"redirectUrl\":\"http://10.16.0.12:8081/?usermac=4C-6F-9C-02-E2-C5&userip=10.21.91.241&origurl=http://edge.microsoft.com/captiveportal/generate_204&nasip=10.100.0.1\",\"type\":\"login\"}");

RequestBody body = RequestBody.create(mediaType, "{\"deviceType\":\"Android\",\"webAuthUser\":\"" + namePost +"\",\"webAuthPassword\":\""+ passwordPost+"\",\"redirectUrl\":\"http://10.16.0.12:8081/?usermac=" + macPost + "&userip="+ ipPost +"&origurl=http://edge.microsoft.com/captiveportal/generate_204&nasip=10.100.0.1\",\"type\":\"login\"}");
Log.d(TAG,"{\"deviceType\":\"Android\",\"webAuthUser\":\"" + namePost +"\",\"webAuthPassword\":\""+ passwordPost+"\",\"redirectUrl\":\"http://10.16.0.12:8081/?usermac=" + macPost + "&userip="+ ipPost +"&origurl=http://edge.microsoft.com/captiveportal/generate_204&nasip=10.100.0.1\",\"type\":\"login\"}");
Request request = new Request.Builder()
.url("http://10.16.0.12:8081/portal/api/v2/online?noCache=1605885991204")
.method("POST", body)
.addHeader("accept", "*/*")
.addHeader("accept-encoding", "gzip, deflate")
.addHeader("accept-language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6")
.addHeader("authorization", "d258e916aa384de449a489e2abf0642e394dc69548cdbdda602fa64a6f3469de083c110756e9cefd9270b6d7cc354ff123223db4cf860564")
.addHeader("content-length", "251")
.addHeader("content-type", "application/json")
// .addHeader("cookie", "redirectUrl=http://10.16.0.12:8081/?usermac=2C-61-04-FF-73-68&userip=10.22.193.12&origurl=http://edge.microsoft.com/captiveportal/generate_204&nasip=10.100.0.1; token=d258e916aa384de449a489e2abf0642e394dc69548cdbdda602fa64a6f3469de083c110756e9cefd9270b6d7cc354ff123223db4cf860564")
.addHeader("dnt", "1")
.addHeader("host", "10.16.0.12:8081")
.addHeader("origin", "http://10.16.0.12:8081")
.addHeader("proxy-connection", "keep-alive")
.addHeader("referer", "http://10.16.0.12:8081/login")
.addHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 Edg/86.0.622.69")
.build();
// Response response = client.newCall(request).execute();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
Log.d(TAG,e.getMessage());
}

@Override
public void onResponse(Call call, Response response) throws IOException {
Log.d(TAG,"登录成功啦");



}
});
}


}
Loading

0 comments on commit 4fb054e

Please sign in to comment.