Skip to content

Commit

Permalink
added defaultly enabled checkbox to hide unmatched metrics in inspect…
Browse files Browse the repository at this point in the history
…or, merged in experimental work by ATamimi for a new scoring algorithm, misc fixes
  • Loading branch information
ESIC-DA committed Nov 7, 2018
1 parent 72e56b1 commit 43d9566
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 43 deletions.
6 changes: 3 additions & 3 deletions MetricsTable.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# Valid range of the points column is -100 to 100 inclusive.

# The fifth column is the platform name. "Multiplatform" is a special name (exact spelling, case insensitive) which attributes this score line to any platform. Any other term here (used consistently) will lump that
score line in together with others with the same identifier. This is used when calculating the maximum score, which is the max of multiplatform plus the platform with the largest individual max score.
(i.e. if multiplatform is 70, windows is 30, and linux is 20, then the score banding used to color the GUI will be out of 100 (the max platform is 30, plus multiplatform 70 is 100))
There is another special platform called "optional" (exact spelling, case insensitive) which will count that line against no platforms, which will keep it from increasing the maximum score
# score line in together with others with the same identifier. This is used when calculating the maximum score, which is the max of multiplatform plus the platform with the largest individual max score.
# (i.e. if multiplatform is 70, windows is 30, and linux is 20, then the score banding used to color the GUI will be out of 100 (the max platform is 30, plus multiplatform 70 is 100))
# There is another special platform called "optional" (exact spelling, case insensitive) which will count that line against no platforms, which will keep it from increasing the maximum score

# The last column is not currently parsed, but should be used for comments which a future version of the GUI might display

Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<property name="build.numThreads" value="1" />
<property name="src.dir" value="./src"/>
<property name="lib.dir" value="./deps/org.graphstream/lib"/>
<property name="build.version" value="AHA-GUI v0.6.3a1"/>
<property name="build.version" value="AHA-GUI v0.6.3a2"/>
<property name="CP" value="."/>
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm" />
Expand Down
39 changes: 29 additions & 10 deletions src/esic/AHAGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public AHAGUI(AHAModel model)
m_model=model;
setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
setSize(1152, 768);
setTitle(AHAGUI.class.getPackage().getImplementationVersion().split(" B")[0]); //This should result in something like "AHA-GUI v0.5.6b1" being displayed
String title="AHA-GUI";
try { title=AHAGUI.class.getPackage().getImplementationVersion().split(" B")[0]; } catch (Exception e) {}
setTitle(title); //This should result in something like "AHA-GUI v0.5.6b1" being displayed
getRootPane().setBorder(new javax.swing.border.LineBorder(java.awt.Color.GRAY,2)); //TODO: tried this to clean up the weird dashed appearance of the right gray border on macOS, but to no avail. figure it out later.
setLayout(new java.awt.BorderLayout(2,0));

Expand Down Expand Up @@ -322,14 +324,15 @@ public String getToolTipText(java.awt.event.MouseEvent e)

public static class InspectorWindow extends javax.swing.JFrame
{
private javax.swing.JCheckBox m_changeOnMouseOver=new javax.swing.JCheckBox("Update on MouseOver",false), m_showScoringSpecifics=new javax.swing.JCheckBox("Show Score Metric Specifics",false);
private javax.swing.JCheckBox m_showOnlyMatchedMetrics=new javax.swing.JCheckBox("Show Only Matched Metrics",true), m_changeOnMouseOver=new javax.swing.JCheckBox("Update on MouseOver",false), m_showScoringSpecifics=new javax.swing.JCheckBox("Show Score Metric Specifics",false);
private String[][] m_inspectorWindowColumnHeaders={{"Info"},{"Open Internal Port", "Proto"},{"Open External Port", "Proto"},{"Connected Process Name", "PID"}, {"Score Metric", "Value"}};
private String[][] m_inspectorWindowColumnTooltips={{"Info"},{"Port that is able to be connected to from other processes internally.", "Protocol in use."},{"Port that is able to be connected to from other external hosts/processes.", "Protocol in use."},{"Names of processes connected to this one", "Process Identifier"}, {"The scoring metric checked against.", "Result of the checked metric."}};
private javax.swing.JTable[] m_inspectorWindowTables= new javax.swing.JTable[m_inspectorWindowColumnHeaders.length]; //if you need more tables just add another column header set above

public InspectorWindow(javax.swing.JFrame parent)
{
setTitle("Graph Node Inspector");
m_showOnlyMatchedMetrics.setToolTipText(styleToolTipText("Only displays metrics which were matched, for example if ASLR was true (Note: please click on a new node after enabling)."));
m_showScoringSpecifics.setToolTipText(styleToolTipText("Shows the specific metric in the inspector above that matched (Note: please click on a new node after enabling)."));
m_changeOnMouseOver.setToolTipText(styleToolTipText("Enable change of the inspector above on hovering over nodes in addition to clicking."));

Expand All @@ -345,6 +348,7 @@ public InspectorWindow(javax.swing.JFrame parent)

javax.swing.JPanel panel=new javax.swing.JPanel(); //easiest way to get these things to be compact vertically...tried everything with insets to no avail
panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.Y_AXIS));
panel.add(m_showOnlyMatchedMetrics);
panel.add(m_showScoringSpecifics);
panel.add(m_changeOnMouseOver);

Expand Down Expand Up @@ -416,18 +420,33 @@ public void updateDisplayForGraphElement(org.graphstream.ui.graphicGraph.Graphic
} catch (Exception e) { e.printStackTrace(); }
try
{ //update the fifth "Score Metric" table
String[] scores=getNodeScoreReasonString(node, true).split(", ");
scoreReasons=new String[scores.length][2];
String score=getNodeScoreReasonString(node, true);
//System.err.println(score);
String[] scores=score.split(", ");
int length=0;
for (int i=0;i<scores.length;i++)
{
scoreReasons[i]=scores[i].split("=");
if (!m_showScoringSpecifics.isSelected())
{
String input=(String)scoreReasons[i][0];
if (input!=null && input.contains("[") && input.contains("]:")) { scoreReasons[i][0]=input.split("\\.")[0]+"("+input.split("\\]:")[1]+")"; }
if (scores[i].toLowerCase().endsWith("false") && m_showOnlyMatchedMetrics.isSelected()) {continue;}
length++;
}
scoreReasons=new String[length][2];
int j=0;
for (int i=0;i<scores.length;i++)
{
String[] scrTokens=scores[i].split("=");
if (scrTokens!=null && scrTokens.length>=2)
{
if (m_showOnlyMatchedMetrics.isSelected()==true && scrTokens[1].toLowerCase().contains("false")) { continue; }
scoreReasons[j]=scrTokens;
if (!m_showScoringSpecifics.isSelected())
{
String input=(String)scoreReasons[j][0];
if (input!=null && input.contains("[") && input.contains("]:")) { scoreReasons[j][0]=input.split("\\.")[0]+"("+input.split("\\]:")[1]+")"; }
}
j++;
}
}
if (scores.length==0){ scoreReasons=new String[][]{{"No score results found"}}; }
if (scores.length==0 || score.trim().trim().equals("N/A") ){ scoreReasons=new String[][]{{"Scoring not applicable."}}; }
} catch (Exception e) { e.printStackTrace(); }

final Object[][][] data={infoData,intPorts,extPorts,connectionData,scoreReasons}; // create final pointer to pass to swing.infokelater. as long as this order of these object arrays is correct, everything will work :)
Expand Down
Loading

0 comments on commit 43d9566

Please sign in to comment.