1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
diff --git a/armitage/src/main/resources/scripts/targets.sl b/armitage/src/main/resources/scripts/targets.sl
index 864f7518..b1e431f1 100644
--- a/armitage/src/main/resources/scripts/targets.sl
+++ b/armitage/src/main/resources/scripts/targets.sl
@@ -122,6 +122,12 @@ on sessions {
}
}
+ # refresh our service port table
+ local('$services $service $svc_string $port_string $host2 $port $proto $name');
+ call_async_callback($mclient, "db.services", $this);
+ yield;
+ $services = convertAll($1);
+
# create a data structure with id, description, icon, and tooltip
foreach $id => $host (%hosts) {
local('$tooltip');
@@ -132,8 +138,23 @@ on sessions {
$tooltip = "I know nothing about $id";
}
+ $svc_string = "";
+ if ('services' in $services) {
+ foreach $service ($services['services']) {
+ ($host2, $port, $name) = values($service, @('host', 'port', 'name'));
+ if($host2 eq $id) {
+ $port_string = $name . "(" . $port . ")";
+ if($svc_string eq "") {
+ $svc_string = $port_string;
+ } else {
+ $svc_string = $svc_string . "," . $port_string;
+ }
+ }
+ }
+ }
+
if ($host['show'] eq "1") {
- [$refresh addNode: $id, $host['label'] . "", describeHost($host), showHost($host), $tooltip];
+ [$refresh addNode: $id, $svc_string, $host['label'] . "", describeHost($host), showHost($host), $tooltip];
}
}
diff --git a/armitage/src/main/java/graph/NetworkGraph.java b/armitage/src/main/java/graph/NetworkGraph.java
index 859b0ffe..3f3d0784 100644
--- a/armitage/src/main/java/graph/NetworkGraph.java
+++ b/armitage/src/main/java/graph/NetworkGraph.java
@@ -445,7 +445,7 @@ public void setRoutes(Route[] routes) {
protected Map tooltips = new HashMap();
- public Object addNode(String id, String label, String description, Image image, String tooltip) {
+ public Object addNode(String id, String services, String label, String description, Image image, String tooltip) {
nodeImages.put(id, image);
if (label.length() > 0) {
diff --git a/armitage/src/main/java/graph/RefreshGraph.java b/armitage/src/main/java/graph/RefreshGraph.java
index 803b26c9..76fdea98 100644
--- a/armitage/src/main/java/graph/RefreshGraph.java
+++ b/armitage/src/main/java/graph/RefreshGraph.java
@@ -17,6 +17,7 @@
private static class Node {
public String id = "";
+ public String services = "";
public String label = "";
public String description = "";
public Image iconz = null;
@@ -36,9 +37,10 @@ public void addRoute(Route route) {
routes.add(route);
}
- public void addNode(String id, String label, String description, Image iconz, String tooltip) {
+ public void addNode(String id, String services, String label, String description, Image iconz, String tooltip) {
Node n = new Node();
n.id = id;
+ n.services = services;
n.label = label;
n.description = description;
n.iconz = iconz;
@@ -60,7 +62,7 @@ public void run() {
Iterator i = nodes.iterator();
while (i.hasNext()) {
Node n = (Node)i.next();
- graph.addNode(n.id, n.label, n.description, n.iconz, n.tooltip);
+ graph.addNode(n.id, n.services, n.label, n.description, n.iconz, n.tooltip);
}
/* setup routes */
diff --git a/armitage/src/main/java/graph/Refreshable.java b/armitage/src/main/java/graph/Refreshable.java
index 47d740fe..6d1739d8 100644
--- a/armitage/src/main/java/graph/Refreshable.java
+++ b/armitage/src/main/java/graph/Refreshable.java
@@ -7,7 +7,7 @@
public void start();
/* add a node */
- public Object addNode(String id, String label, String description, Image image, String tooltip);
+ public Object addNode(String id, String services, String label, String description, Image image, String tooltip);
/* setup all of our routes in one fell swoop */
public void setRoutes(Route[] routes);
diff --git a/armitage/src/main/java/table/NetworkTable.java b/armitage/src/main/java/table/NetworkTable.java
index da265458..c29811a9 100644
--- a/armitage/src/main/java/table/NetworkTable.java
+++ b/armitage/src/main/java/table/NetworkTable.java
@@ -15,6 +15,7 @@
import graph.Route;
import graph.GraphPopup;
import graph.Refreshable;
+import java.util.regex.PatternSyntaxException;
public class NetworkTable extends JComponent implements ActionListener, Refreshable {
protected JScrollPane scroller = null;
@@ -48,15 +49,17 @@ public NetworkTable() {
}
protected GenericTableModel model;
+ protected TableRowSorter sorter;
+ protected JTextField searchField;
protected JTable table;
protected int height;
public NetworkTable(Properties display) {
this.display = display;
- model = new GenericTableModel(new String[] { " ", "Address", "Label", "Description", "Pivot" }, "Address", 256);
+ model = new GenericTableModel(new String[] { " ", "Address", "Services", "Label", "Description", "Pivot" }, "Address", 256);
table = new ATable(model);
- TableRowSorter sorter = new TableRowSorter(model);
+ sorter = new TableRowSorter(model);
sorter.toggleSortOrder(1);
Comparator hostCompare = new Comparator() {
@@ -152,13 +155,47 @@ public void all(MouseEvent ev) {
public void mouseReleased(MouseEvent ev) { all(ev); }
});
- setLayout(new BorderLayout());
+ searchField = new JTextField("");
+ searchField.getDocument().addDocumentListener(new DocumentListener() {
+ @Override public void insertUpdate(DocumentEvent e) {
+ fireDocumentChangeEvent();
+ }
+ @Override public void removeUpdate(DocumentEvent e) {
+ fireDocumentChangeEvent();
+ }
+ @Override public void changedUpdate(DocumentEvent e) { /* not needed */ }
+ });
+ fireDocumentChangeEvent();
+
+ JPanel searchPanel = new JPanel(new BorderLayout());
+ searchPanel.add(new JLabel("Regex filter:"),BorderLayout.WEST);
+ searchPanel.add(searchField);
+
scroller = new JScrollPane(table);
- add(scroller, BorderLayout.CENTER);
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(searchPanel,BorderLayout.NORTH);
+ mainPanel.add(scroller);
+
+ setLayout(new BorderLayout());
+ add(mainPanel, BorderLayout.CENTER);
setupShortcuts();
}
+ private void fireDocumentChangeEvent() {
+ searchField.setBackground(Color.WHITE);
+ String pattern = searchField.getText().trim();
+ if (pattern.isEmpty()) {
+ sorter.setRowFilter(null);
+ } else {
+ try {
+ sorter.setRowFilter(RowFilter.regexFilter(pattern));
+ } catch (PatternSyntaxException ex) {
+ searchField.setBackground(Color.PINK);
+ }
+ }
+ }
+
public void setupWidths() {
table.getColumn("Address").setPreferredWidth((int)(125 * zoom));
table.getColumn("Label").setPreferredWidth((int)(125 * zoom));
@@ -269,7 +306,7 @@ public String getCellAt(Point p) {
public void setAutoLayout(String layout) {
}
- public Object addNode(String id, String label, String description, Image image, String tooltip) {
+ public Object addNode(String id, String services, String label, String description, Image image, String tooltip) {
if (id == null || label == null)
return null;
@@ -278,6 +315,7 @@ public Object addNode(String id, String label, String description, Image image,
if (description.indexOf(id) > -1)
description = description.substring(id.length());
+ map.put("Services", services);
map.put("Label", label);
map.put("Description", description);
map.put("Tooltip", tooltip);
|