用java打造一個生成cookies和headers字典的工具
阿新 • • 發佈:2018-06-03
replace .com 輸入 ted int avi click 技術分享 ati
先上效果圖:
經常抓包時出來的數據是這樣的:
每次模擬的話都需要手動構建這些數據的鍵值對
這個操作很繁瑣而且很容易出錯所以我準備做一個這種小工具
分析文本發現可以直接搜索替換
java源代碼:
package com.mycompany.myapp2; import android.app.*; import android.os.*; import android.view.*; import android.widget.*; public class MainActivity extends Activity { String a=""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } public void onHeadersButtonClick(View view) { TextView textView3 = (TextView) findViewById(R.id.mainEditText1); textView3.getText(); a=a+textView3.getText(); String b= a.replace("\n","‘,\n‘"); b=b.replace(": ","‘:‘"); b="{\n‘"+b+"‘\n}"; TextView textView2 = (TextView) findViewById(R.id.mainEditText2); textView2.setText(b); a=""; } public void onCookiesButtonClick(View view) { TextView textView3 = (TextView) findViewById(R.id.mainEditText1); //textView3.getText(); a=a+textView3.getText(); String b= a.replace(" ",""); b=b.replace(";","‘,\n‘"); //b=b.replace(";\n","‘,\n‘"); b=b.replace("=","‘:‘"); b="{\n‘"+b+"‘\n}"; TextView textView2 = (TextView) findViewById(R.id.mainEditText2); textView2.setText(b); a=""; } }
布局的xml代碼:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="top|center"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="200dp" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="CCOOKIES OR HEADERS:" android:textSize="20sp"/> <EditText android:layout_width="match_parent" android:ems="10" android:layout_height="match_parent" android:hint="請輸入原數據:" android:gravity="top" android:id="@+id/mainEditText1"/> </LinearLayout> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="COOKIES TO DICTS" android:onClick="onCookiesButtonClick"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="headers TO DICTS" android:onClick="onHeadersButtonClick"/> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="DICTS:" android:textSize="20sp"/> <EditText android:layout_width="match_parent" android:ems="10" android:layout_height="match_parent" android:hint="轉換結果在這裏:" android:gravity="top" android:id="@+id/mainEditText2"/> </LinearLayout> </LinearLayout>
效果圖:
用java打造一個生成cookies和headers字典的工具