| skipped 15 lines |
16 | 16 | | void IPTool::clearResults(){ |
17 | 17 | | /* clear the results */ |
18 | 18 | | switch (ui->comboBoxOption->currentIndex()) { |
19 | | - | case 0: // DNS |
| 19 | + | case 0: // REVERSE IP |
20 | 20 | | m_model_dns->clear(); |
21 | 21 | | m_model_dns->setHorizontalHeaderLabels({tr(" IP"), tr(" Hostname")}); |
22 | | - | set_subdomain.clear(); |
23 | 22 | | break; |
24 | | - | case 1: |
| 23 | + | case 1: // PORT |
25 | 24 | | m_model_port->clear(); |
26 | 25 | | m_model_port->setHorizontalHeaderLabels({tr(" IP"), tr(" Ports")}); |
| 26 | + | set_ports.clear(); |
27 | 27 | | break; |
28 | | - | case 2: |
| 28 | + | case 2: // PING |
29 | 29 | | m_model_ping->clear(); |
30 | 30 | | m_model_ping->setHorizontalHeaderLabels({tr(" IP"), tr(" Time(ms)")}); |
31 | 31 | | break; |
| skipped 16 lines |
48 | 48 | | QModelIndexList selectedIndexes = model_selectedIndexes.indexes(); |
49 | 49 | | switch (ui->comboBoxOption->currentIndex()) { |
50 | 50 | | case 0: // DNS |
51 | | - | for(QModelIndexList::const_iterator i = selectedIndexes.constEnd()-1; i >= selectedIndexes.constBegin(); --i){ |
52 | | - | set_subdomain.remove(i->data().toString()); |
| 51 | + | for(QModelIndexList::const_iterator i = selectedIndexes.constEnd()-1; i >= selectedIndexes.constBegin(); --i) |
53 | 52 | | m_model_dns->removeRow(i->row()); |
54 | | - | } |
55 | 53 | | break; |
56 | 54 | | case 1: // PORT |
57 | 55 | | for(QModelIndexList::const_iterator i = selectedIndexes.constEnd()-1; i >= selectedIndexes.constBegin(); --i){ |
58 | | - | set_subdomain.remove(i->data().toString()); |
| 56 | + | set_ports.remove(i->data().toString()); |
59 | 57 | | m_model_port->removeRow(i->row()); |
60 | 58 | | } |
61 | 59 | | break; |
62 | 60 | | case 2: // PING |
63 | | - | for(QModelIndexList::const_iterator i = selectedIndexes.constEnd()-1; i >= selectedIndexes.constBegin(); --i){ |
64 | | - | set_subdomain.remove(i->data().toString()); |
| 61 | + | for(QModelIndexList::const_iterator i = selectedIndexes.constEnd()-1; i >= selectedIndexes.constBegin(); --i) |
65 | 62 | | m_model_ping->removeRow(i->row()); |
66 | | - | } |
67 | 63 | | } |
68 | 64 | | |
69 | 65 | | ui->labelResultsCount->setNum(proxyModel->rowCount()); |
| skipped 16 lines |
86 | 82 | | switch(result_type){ |
87 | 83 | | case RESULT_TYPE::SUBDOMAIN: |
88 | 84 | | for(int i = 0; i != proxyModel->rowCount(); ++i) |
89 | | - | file.write(proxyModel->index(i, 0).data().toString().append(NEWLINE).toUtf8()); |
| 85 | + | file.write(proxyModel->index(i, 1).data().toString().append(NEWLINE).toUtf8()); |
90 | 86 | | break; |
91 | 87 | | |
92 | 88 | | case RESULT_TYPE::IP: |
93 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
94 | | - | QString ipv4(proxyModel->index(i, 1).data().toString()); |
95 | | - | QString ipv6(proxyModel->index(i, 2).data().toString()); |
96 | | - | if(!ipv4.isEmpty()) |
97 | | - | file.write(ipv4.append(NEWLINE).toUtf8()); |
98 | | - | if(!ipv6.isEmpty()) |
99 | | - | file.write(ipv6.append(NEWLINE).toUtf8()); |
100 | | - | } |
| 89 | + | for(int i = 0; i != proxyModel->rowCount(); ++i) |
| 90 | + | file.write(proxyModel->index(i, 0).data().toString().append(NEWLINE).toUtf8()); |
101 | 91 | | break; |
102 | 92 | | |
103 | | - | case RESULT_TYPE::CSV: |
104 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
105 | | - | QString host(proxyModel->index(i, 0).data().toString()); |
106 | | - | QString ipv4(proxyModel->index(i, 1).data().toString()); |
107 | | - | QString ipv6(proxyModel->index(i, 2).data().toString()); |
108 | | - | |
109 | | - | if(!ipv4.isEmpty()) |
110 | | - | host.append(",").append(ipv4); |
111 | | - | if(!ipv6.isEmpty()) |
112 | | - | host.append(",").append(ipv6); |
113 | | - | |
114 | | - | file.write(host.append(NEWLINE).toUtf8()); |
115 | | - | } |
116 | | - | break; |
117 | | - | |
118 | | - | case RESULT_TYPE::JSON: |
119 | | - | { |
120 | | - | QJsonDocument document; |
121 | | - | QJsonArray array; |
122 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
123 | | - | QModelIndex model_index = proxyModel->mapToSource(proxyModel->index(i, 0)); |
124 | | - | s3s_item::HOST *item = static_cast<s3s_item::HOST*>(m_model_dns->itemFromIndex(model_index)); |
125 | | - | array.append(host_to_json(item)); |
126 | | - | } |
127 | | - | document.setArray(array); |
128 | | - | file.write(document.toJson()); |
129 | | - | break; |
130 | | - | } |
131 | | - | |
132 | 93 | | default: |
133 | 94 | | break; |
134 | 95 | | } |
| skipped 29 lines |
164 | 125 | | switch(result_type){ |
165 | 126 | | case RESULT_TYPE::SUBDOMAIN: |
166 | 127 | | for(int i = 0; i != proxyModel->rowCount(); ++i) |
167 | | - | clipboardData.append(proxyModel->index(i, 0).data().toString()).append(NEWLINE); |
| 128 | + | clipboardData.append(proxyModel->index(i, 1).data().toString()).append(NEWLINE); |
168 | 129 | | break; |
169 | 130 | | |
170 | 131 | | case RESULT_TYPE::IP: |
171 | 132 | | for(int i = 0; i != proxyModel->rowCount(); ++i) |
172 | | - | { |
173 | | - | QString ipv4(proxyModel->index(i, 1).data().toString()); |
174 | | - | QString ipv6(proxyModel->index(i, 2).data().toString()); |
175 | | - | if(!ipv4.isEmpty()) |
176 | | - | clipboardData.append(ipv4).append(NEWLINE); |
177 | | - | if(!ipv6.isEmpty()) |
178 | | - | clipboardData.append(ipv6).append(NEWLINE); |
179 | | - | } |
180 | | - | break; |
181 | | - | |
182 | | - | case RESULT_TYPE::CSV: |
183 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i) |
184 | | - | { |
185 | | - | QString host(proxyModel->index(i, 0).data().toString()); |
186 | | - | QString ipv4(proxyModel->index(i, 1).data().toString()); |
187 | | - | QString ipv6(proxyModel->index(i, 2).data().toString()); |
188 | | - | |
189 | | - | if(!ipv4.isEmpty()) |
190 | | - | host.append(",").append(ipv4); |
191 | | - | if(!ipv6.isEmpty()) |
192 | | - | host.append(",").append(ipv6); |
193 | | - | |
194 | | - | clipboardData.append(host).append(NEWLINE); |
195 | | - | } |
196 | | - | break; |
197 | | - | |
198 | | - | case RESULT_TYPE::JSON: |
199 | | - | { |
200 | | - | QJsonDocument document; |
201 | | - | QJsonArray array; |
202 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
203 | | - | QModelIndex model_index = proxyModel->mapToSource(proxyModel->index(i, 0)); |
204 | | - | s3s_item::HOST *item = static_cast<s3s_item::HOST*>(m_model_dns->itemFromIndex(model_index)); |
205 | | - | array.append(host_to_json(item)); |
206 | | - | } |
207 | | - | document.setArray(array); |
208 | | - | clipboardData.append(document.toJson()); |
209 | | - | } |
| 133 | + | clipboardData.append(proxyModel->index(i, 0).data().toString()).append(NEWLINE); |
210 | 134 | | break; |
211 | 135 | | |
212 | 136 | | default: |
| skipped 13 lines |
226 | 150 | | clipboard->setText(data.trimmed()); |
227 | 151 | | } |
228 | 152 | | |
229 | | - | void IPTool::extract(bool subdomain, bool tld){ |
230 | | - | QClipboard *clipboard = QGuiApplication::clipboard(); |
231 | | - | QSet<QString> extracts; |
232 | | - | |
233 | | - | /* extracting and saving to a set to avoid repeatition */ |
234 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
235 | | - | if(subdomain) |
236 | | - | extracts.insert(proxyModel->index(i, 0).data().toString().split(".").at(0)); |
237 | | - | if(tld) |
238 | | - | extracts.insert(proxyModel->index(i, 0).data().toString().split(".").last()); |
239 | | - | } |
240 | | - | |
241 | | - | /* setting the data to clipboard */ |
242 | | - | QString data; |
243 | | - | foreach(const QString &extract, extracts) |
244 | | - | data.append(extract).append(NEWLINE); |
245 | | - | clipboard->setText(data.trimmed()); |
246 | | - | } |
247 | | - | |
248 | | - | void IPTool::extractSelected(bool subdomain, bool tld){ |
249 | | - | QClipboard *clipboard = QGuiApplication::clipboard(); |
250 | | - | QSet<QString> extracts; |
251 | | - | |
252 | | - | /* extracting and saving to a set to avoid repeatition */ |
253 | | - | foreach(const QModelIndex &index, selectionModel->selectedIndexes()){ |
254 | | - | if(index.column()) |
255 | | - | continue; |
256 | | - | |
257 | | - | if(subdomain) |
258 | | - | extracts.insert(index.data().toString().split(".").at(0)); |
259 | | - | if(tld) |
260 | | - | extracts.insert(index.data().toString().split(".").last()); |
261 | | - | } |
262 | | - | |
263 | | - | /* setting the data to clipboard */ |
264 | | - | QString data; |
265 | | - | foreach(const QString &extract, extracts) |
266 | | - | data.append(extract).append(NEWLINE); |
267 | | - | clipboard->setText(data.trimmed()); |
268 | | - | } |
269 | | - | |
270 | 153 | | /// |
271 | 154 | | /// sending results... |
272 | 155 | | /// |
| skipped 2 lines |
275 | 158 | | for(int i = 0; i != proxyModel->rowCount(); ++i) |
276 | 159 | | { |
277 | 160 | | QModelIndex index = proxyModel->mapToSource(proxyModel->index(i ,0)); |
278 | | - | s3s_item::HOST *item = static_cast<s3s_item::HOST*>(m_model_dns->itemFromIndex(index)); |
279 | | - | project->addActiveHost(host_to_struct(item)); |
| 161 | + | s3s_item::IPTool *item = static_cast<s3s_item::IPTool*>(m_model_port->itemFromIndex(index)); |
| 162 | + | project->addActiveIP(iptool_to_struct(item)); |
280 | 163 | | } |
281 | 164 | | } |
282 | 165 | | |
| skipped 2 lines |
285 | 168 | | if(index.column()) |
286 | 169 | | continue; |
287 | 170 | | QModelIndex model_index = proxyModel->mapToSource(index); |
288 | | - | s3s_item::HOST *item = static_cast<s3s_item::HOST*>(m_model_dns->itemFromIndex(model_index)); |
289 | | - | project->addActiveHost(host_to_struct(item)); |
| 171 | + | s3s_item::IPTool *item = static_cast<s3s_item::IPTool*>(m_model_port->itemFromIndex(model_index)); |
| 172 | + | project->addActiveIP(iptool_to_struct(item)); |
290 | 173 | | } |
291 | 174 | | } |
292 | 175 | | |
| skipped 4 lines |
297 | 180 | | switch (result_type) { |
298 | 181 | | case RESULT_TYPE::SUBDOMAIN: |
299 | 182 | | for(int i = 0; i != proxyModel->rowCount(); ++i) |
300 | | - | targets.insert(proxyModel->index(i, 0).data().toString()); |
| 183 | + | targets.insert(proxyModel->index(i, 1).data().toString()); |
301 | 184 | | break; |
302 | 185 | | case RESULT_TYPE::IP: |
303 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
304 | | - | targets.insert(proxyModel->index(i, 1).data().toString()); |
305 | | - | targets.insert(proxyModel->index(i, 2).data().toString()); |
306 | | - | } |
| 186 | + | for(int i = 0; i != proxyModel->rowCount(); ++i) |
| 187 | + | targets.insert(proxyModel->index(i, 0).data().toString()); |
307 | 188 | | break; |
308 | 189 | | default: |
309 | 190 | | break; |
| skipped 45 lines |
355 | 236 | | switch (result_type) { |
356 | 237 | | case RESULT_TYPE::SUBDOMAIN: |
357 | 238 | | foreach(const QModelIndex &index, selectionModel->selectedIndexes()){ |
358 | | - | if(index.column() == 0) |
| 239 | + | if(index.column() == 1) |
359 | 240 | | targets.insert(index.data().toString()); |
360 | 241 | | } |
361 | 242 | | break; |
362 | 243 | | case RESULT_TYPE::IP: |
363 | 244 | | foreach(const QModelIndex &index, selectionModel->selectedIndexes()){ |
364 | | - | if(index.column()) |
| 245 | + | if(index.column() == 0) |
365 | 246 | | targets.insert(index.data().toString()); |
366 | 247 | | } |
367 | 248 | | break; |
| skipped 44 lines |
412 | 293 | | QSet<QString> targets; |
413 | 294 | | |
414 | 295 | | /* getting the targets */ |
415 | | - | for(int i = 0; i != proxyModel->rowCount(); ++i){ |
416 | | - | targets.insert(proxyModel->index(i, 1).data().toString()); |
417 | | - | targets.insert(proxyModel->index(i, 2).data().toString()); |
418 | | - | } |
| 296 | + | for(int i = 0; i != proxyModel->rowCount(); ++i) |
| 297 | + | targets.insert(proxyModel->index(i, 0).data().toString()); |
419 | 298 | | |
420 | 299 | | /* sending the targets */ |
421 | 300 | | switch (tool) { |
| skipped 11 lines |
433 | 312 | | |
434 | 313 | | /* getting the targets */ |
435 | 314 | | foreach(const QModelIndex &index, selectionModel->selectedIndexes()){ |
436 | | - | if(index.column()) |
| 315 | + | if(index.column() == 0) |
437 | 316 | | targets.insert(index.data().toString()); |
438 | 317 | | } |
439 | 318 | | |
| skipped 23 lines |