Skip to content

Commit e2cc5fb

Browse files
committed
Some cat.net fixes
Added couple jni4net extension methods
1 parent eaa405e commit e2cc5fb

13 files changed

+681
-241
lines changed

3rdParty/Jni4Net/API_Jni4Net.cs

Lines changed: 475 additions & 0 deletions
Large diffs are not rendered by default.

3rdParty/Jni4Net/API_Jni4Net_Active.cs

Lines changed: 0 additions & 189 deletions
This file was deleted.

3rdParty/Jni4Net/PoC - Jni4Net - Classes, Methods, Fields in target.h2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bridge.CreateJVM(new BridgeSetup(){Verbose=true}); //only needs to be called onc
22

33
var topPanel = "PoC - Jni4Net - Classes, Methods, Fields in target".popupWindow(1000,400);
44
//var topPanel = panel.add_Panel(true);
5-
5+
66
var actionPanel = topPanel.insert_ActionPanel();
77
var decompileClasses = false;
88
//var treeView = topPanel.insert_Left().add_TreeView_with_PropertyGrid().sort();
@@ -15,9 +15,9 @@ actionPanel.add_Link("REPL selectedNode", ()=> treeView.selected().Tag.script_Me
1515

1616
treeView.java_SetTreeView_To_Show_Jni4Net_Reflection_Data();
1717

18-
var jni4Net_Active = new API_Jni4Net_Active();
18+
var jni4Net = new API_Jni4Net();
1919

20-
var classes = jni4Net_Active.java_From_ClassLoader_get_Loaded_Classes();
20+
var classes = jni4Net.java_From_ClassLoader_get_Loaded_Classes();
2121

2222
Action<string> showClasses =
2323
(filter)=>{
@@ -83,5 +83,5 @@ return "done";
8383
//using net.sf.jni4net.adaptors
8484
//O2Ref:Jni4Net/lib/jni4net.n-0.8.6.0.dll
8585

86-
//O2File:API_Jni4Net_Active.cs
86+
//O2File:API_Jni4Net.cs
8787
//O2File:API_Jad.cs

3rdParty/Jni4Net/PoC - Jni4Net - List JavaProperties.h2

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?xml version="1.0"?>
2-
<H2>
3-
<SourceCode>//Environment.setEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Java\jre7");
1+
//Environment.setEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Java\jre7");
42
O2Setup.extractEmbededConfigZips();
53
var topPanel = "PoC - Jni4Net - List JavaProperties: {0}".format(clr.details()).popupWindow().insert_LogViewer();
64
var tableList = topPanel.clear().add_TableList("Java Properties").add_Columns("Key", "Value");
@@ -28,11 +26,8 @@ return "ok";
2826
//using java.lang;
2927
//using java.util;
3028
//using net.sf.jni4net;
31-
//using net.sf.jni4net.adaptors;
29+
//using net.sf.jni4net.adaptors;
3230
//O2Ref:Jni4Net/lib/jni4net.n-0.8.6.0.dll
3331
//_O2Ref:E:\_Code_Tests\Jni4Net\jni4net-read-only\target\jni4net-0.8.7.0-bin\lib\jni4net.n-0.8.7.0.dll
3432
//O2File:API_ConsoleOut.cs
35-
//O2EmbedTool:Jni4Net
36-
</SourceCode>
37-
<ReferencedAssemblies />
38-
</H2>
33+
//O2EmbedTool:Jni4Net

3rdParty/Microsoft/CatNet/AndRolsyn/Package - Roslyn Cat.Net- Compile and Scan Solution.h2

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?xml version="1.0"?>
2-
<H2>
3-
<SourceCode>//Package - Roslyn Cat.Net- Compile and Scan Solution.h2
1+
//Package - Roslyn Cat.Net- Compile and Scan Solution.h2
42

53
//var topPanel = "{name}".popupWindow(700,400);
64
var scriptFile = "Util - Roslyn Cat.Net- Compile and Scan Solution.h2";
@@ -9,8 +7,8 @@ var pathToAssemblies = "";
97
var projectFile = "";
108
var compiledScript = "";
119

12-
Action&lt;List&lt;string&gt;&gt; beforeAddingReferences =
13-
(referencesToAdd)=&gt; {
10+
Action<List<string>> beforeAddingReferences =
11+
(referencesToAdd)=> {
1412
foreach(var file in referencesToAdd.toList())
1513
if(file.fileName_Is("O2_External_SharpDevelop.dll","Ionic.Zip.dll", "Mono.Cecil.dll","QuickGraph.dll",
1614
"Microsoft.ACESec.CATNet.Core.dll","WeifenLuo.WinFormsUI.Docking.dll"
@@ -24,8 +22,8 @@ Action&lt;List&lt;string&gt;&gt; beforeAddingReferences =
2422
referencesToAdd.add("Roslyn.Services.CSharp.dll".assembly_Location());
2523
"[in beforeAddingReferences] assembly references: {0}".debug(referencesToAdd.asString());
2624
};
27-
Action&lt;List&lt;string&gt;&gt; beforeEmbedingFiles =
28-
(filesToEmbed)=&gt;{
25+
Action<List<string>> beforeEmbedingFiles =
26+
(filesToEmbed)=>{
2927
"[in beforeEmbedingFiles] assembly references: {0}".debug(filesToEmbed.asString());
3028
};
3129

@@ -41,6 +39,4 @@ createdExe.file_Copy(testFolder);
4139
testFolder.startProcess();
4240

4341
//O2File:API_MicrosoftBuild.cs
44-
//O2File:_Extra_methods_To_Add_to_Main_CodeBase.cs</SourceCode>
45-
<ReferencedAssemblies />
46-
</H2>
42+
//O2File:_Extra_methods_To_Add_to_Main_CodeBase.cs

3rdParty/Microsoft/CatNet/AndRolsyn/RealTime code scanning using Cat.NET and Roslyn.h2

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?xml version="1.0"?>
2-
<H2>
3-
<SourceCode> //var topPanel = panel.clear().add_Panel();
1+
//var topPanel = panel.clear().add_Panel();
42
var topPanel = "PoC - RealTime code scanning using Cat.NET and Roslyn".popupWindow(1000,500).insert_LogViewer();
53

64
API_CatNet_Deployment.ensure_CatNet_Instalation();
@@ -11,7 +9,7 @@ var resultText = codeEditor.insert_Right("Errors and CatNet report file").add_Te
119
var findingsViewer = resultText.parent().parent().insert_Above("CatNet Vulnerabilities").add_FindingsViewer(false);
1210

1311
codeEditor.onTextChange(
14-
(text)=&gt;{
12+
(text)=>{
1513
var compilation = text.tree()
1614
.compiler("test_Assembly_".add_RandomLetters())
1715
.add_Reference("mscorlib")
@@ -28,7 +26,7 @@ codeEditor.onTextChange(
2826
{
2927
resultText.set_Text("");
3028
O2Thread.mtaThread(
31-
()=&gt;{
29+
()=>{
3230
var reportFile = "_catNet_reports__".tempDir(false)
3331
.pathCombine("report.xml");
3432

@@ -89,5 +87,3 @@ codeEditor.set_Text(code, ".cs");
8987
//O2Ref:Roslyn.Compilers.CSharp.dll
9088

9189
//O2Tag_DontAddExtraO2Files
92-
</SourceCode>
93-
</H2>
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
<?xml version="1.0"?>
2-
<H2>
3-
<SourceCode>try
4-
{
5-
1+
try
2+
{
3+
64
O2Setup.extractEmbededConfigZips();
75
var topPanel = "Tool - Simple Cat.NET Scan Gui v1.1".popupWindow(700,400)
86
.set_Form_Icon("cheshire_cat.ico".local());
@@ -12,11 +10,11 @@ var codeViewer = topPanel.insert_Below("Scan results").add_SourceCodeViewer();
1210

1311
API_CatNet_Deployment.ensure_CatNet_Instalation();
1412

15-
Action&lt;string&gt; scanFile =
16-
(target)=&gt;{
13+
Action<string> scanFile =
14+
(target)=>{
1715
if (target.extension(".cs"))
1816
target = target.compileScriptFile(true).location();
19-
if (target.valid() &amp;&amp; target.fileExists())
17+
if (target.valid() && target.fileExists())
2018
{
2119
"Scanning with Cat.NET: {0}".debug(target);
2220
var catNet = new API_CatNet().loadRules();
@@ -29,32 +27,30 @@ Action&lt;string&gt; scanFile =
2927

3028

3129
Action askUserForAssemblyToScan =
32-
()=&gt;{
30+
()=>{
3331
scanFile(topPanel.askUserForFileToOpen());
3432
};
3533
Action scanTestFile =
36-
()=&gt; scanFile("Web_SQL_Injection.cs".local());
34+
()=> scanFile("Web_SQL_Injection.cs".local());
3735
logViewer.onDrop(scanFile);
3836

3937
topPanel.mainMenu().clear()
4038
.add_Menu("File")
4139
.add_MenuItem("Open Assembly to Scan", askUserForAssemblyToScan)
4240
.add_Menu("Debug")
43-
.add_MenuItem("Scan Test File " , ()=&gt;scanTestFile())
44-
.add_MenuItem("Scan HacmeBank .NET" , ()=&gt;scanFile("DotNetGoat.dll".local()))
45-
.add_MenuItem("Open REPL Script" , ()=&gt;topPanel.parentForm().script_Me());
41+
.add_MenuItem("Scan Test File " , ()=>scanTestFile())
42+
.add_MenuItem("Scan HacmeBank .NET" , ()=>scanFile("DotNetGoat.dll".local()))
43+
.add_MenuItem("Open REPL Script" , ()=>topPanel.parentForm().script_Me());
4644

4745
scanTestFile();
48-
}
49-
catch(Exception ex)
50-
{
51-
ex.log("in script body");
46+
}
47+
catch(Exception ex)
48+
{
49+
ex.log("in script body");
5250
}
5351

5452
//O2File:API_CatNet.cs
5553
//O2Package:Web_SQL_Injection.cs
5654
//O2Package:DotNetGoat.dll
5755
//O2Package:cheshire_cat.ico
58-
//O2Embed:E:\TeamMentor\TM_UnitTests\StandAlone_Exes_Packages\CatNet_Files.zip</SourceCode>
59-
<ReferencedAssemblies />
60-
</H2>
56+
//O2Embed:E:\TeamMentor\TM_UnitTests\StandAlone_Exes_Packages\CatNet_Files.zip

0 commit comments

Comments
 (0)