public class MainActivity extends Activity {
String myURL = "https://ssl.kkbox.com.tw/mobile_reg/reg.php?js=yes";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myBrowser=(WebView)findViewById(R.id.webbrowser);
WebSettings websettings = myBrowser.getSettings();
/* 设置WebView的属性,可對網頁進行縮放 */
websettings.setSupportZoom(true);
websettings.setBuiltInZoomControls(true);
/* 设置WebView的属性,此时可以去执行JavaScript脚本 */
websettings.setJavaScriptEnabled(true);
myBrowser.setWebViewClient(new WebViewClient());
myBrowser.loadUrl(myURL);
}
填表與提交:
webView.loadUrl("javascript: {" +
"document.getElementById('username').value = '"+uname +"';" +
"document.getElementById('password').value = '"+password+"';" +
"var frms = document.getElementsByName('loginForm');" +
"frms[0].submit(); };");
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
FARPROC fpAddress;
HMODULE hModule;
BYTE OldCode[5], NewCode[5];
BOOL bHook = false;
void HookOn();
void HookOff();
int WINAPI MyMessageBoxA(HWND hWnd, LPCTSTR lpText,LPCTSTR lpCaption, UINT uType);
BOOL Init();
void HookOn()
{
DWORD OldProtection;
VirtualProtect(fpAddress, 5, PAGE_READWRITE,&OldProtection);
memcpy(fpAddress, NewCode, 5);
VirtualProtect(fpAddress, 5, OldProtection, &OldProtection);
bHook=true;
}
void HookOff()
{
DWORD OldProtection;
VirtualProtect(fpAddress,5, PAGE_READWRITE, &OldProtection);
memcpy(fpAddress, OldCode, 5);
VirtualProtect(fpAddress, 5, OldProtection, &OldProtection);
bHook = false;
}
int WINAPI MyMessageBoxA(HWND hWnd, LPCTSTR lpText,LPCTSTR lpCaption, UINT uType)
{
int nReturn;
HookOff();
nReturn = MessageBoxA(hWnd, "Context", (LPCSTR)lpCaption, MB_OK | MB_ICONINFORMATION);
HookOn();
return(nReturn);
}
BOOL Init()
{
hModule = LoadLibrary(L"user32.dll");
fpAddress = GetProcAddress(hModule, "MessageBoxA");
if(fpAddress == NULL)
return false;
_asm
{
pushad
lea edi, OldCode
mov esi, fpAddress
cld
movsd
movsb
popad
}
NewCode[0] = 0xe9;
_asm
{
lea eax, MyMessageBoxA
mov ebx, fpAddress
sub eax, ebx
sub eax, 5
mov dword ptr [NewCode + 1], eax
}
HookOn();
return(true);
}