我有一个关于用Java解析文本的问题。
Name Virtual address Virtual size Raw size Entropy MD5
CODE 4096 37732 37888 6.56 2c410dfc3efd04d9b69c35c70921424e
DATA 45056 588 1024 2.74 d5ea23d4ecf110fd2591314cbaa84278
BSS 49152 3720 0 0.00 d41d8cd98f00b204e9800998ecf8427e
.idata 53248 2384 2560 4.43 bb5485bf968b970e5ea81292af2acdba
.tls 57344 8 0 0.00 d41d8cd98f00b204e9800998ecf8427e
.rdata 61440 24 512 0.20 9ba824905bf9c7922b6fc87a38b74366
.reloc 65536 2228 0 0.00 d41d8cd98f00b204e9800998ecf8427e
.rsrc 69632 378360 378368 4.42 dc75e95cd49ce06a635cad0b18dab6d7
? Runtime DLLs
c:\docume~1\<USER>~1\locals~1\temp\glc1.tmp (successful)
c:\docume~1\<USER>~1\locals~1\temp\glk2.tmp (successful)
riched32.dll (successful)
secur32.dll (successful)
shell32.dll (successful)
ole32.dll (successful)
setupapi.dll (successful)
rpcrt4.dll (successful)
clbcatq.dll (successful)
comctl32.dll (successful)
ntshrui.dll (successful)
linkinfo.dll (successful)
userenv.dll (successful)
netapi32 (successful)
Contract
? PE imports
[+] advapi32.dll ()
LookupPrivilegeValueA
我想解析运行时DLLS部分中的文本。是否有任何解决方案,当它找到字符串Runtime DLLS时会开始附加到stringbuilder,它会在找到下一个时附加?这与PE IMPORTS有什么关系?或者他们会为此解析选择其他解决方案吗?
答案 0 :(得分:1)
您可以逐行读取文本文件,并在找到字符串&#34;运行时DLL&#34;后开始向stringbuilder添加行。直到找到终点线:
String file = "your_file";
StringBuilder result = new StringBuilder();
boolean flag = false;
try(BufferedReader br = new BufferedReader(new FileReader(file))) {
for(String line; (line = br.readLine()) != null; ) {
if (line.trim().startsWith("? ")) { //lines starting at "? "
flag = !flag;
continue;
}
if (flag) {
//here lines can be parsed to successful or not
result.append(line + "\n");
}
}
}