mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
Export scanning results in SQL format
This commit is contained in:
parent
2e391dc1eb
commit
fee1741dfe
@ -292,6 +292,7 @@ exporter.txt.scanned=Scanned
|
||||
exporter.csv=Comma-separated file (csv)
|
||||
exporter.xml=XML file (xml)
|
||||
exporter.ipList=IP:Port list (lst)
|
||||
exporter.sql=SQL file (sql)
|
||||
exception.FeederException.invalidNetmask=Invalid netmask specified. Must be either in the A.B.C.D or /bits format
|
||||
exception.FeederException.invalidHostname=Invalid or nonexistent hostname specified
|
||||
exception.FeederException.malformedIP=Malformed IP address specified, it should look like A.B.C.D
|
||||
|
||||
@ -256,6 +256,7 @@ exporter.txt.scanned=Σαρωμένα %INFO
|
||||
exporter.csv=Διαχωρισμένα-με κόμμα αρχεία (csv)
|
||||
exporter.xml=Αρχείο XML (xml)
|
||||
exporter.ipList=IP:Λίστα θυρών (lst)
|
||||
|
||||
exception.FeederException.invalidNetmask=Η καθορισμένη μάσκα δεν είναι έγκυρη. Πρέπει να είναι σε μορφή A.B.C.D
|
||||
exception.FeederException.invalidHostname=Το καθορισμένο όνομα υπολογιστή είναι άκυρο ή ανύπαρκτο
|
||||
exception.FeederException.malformedIP=Η καθορισμένη IP διεύθυνση είναι ακατάλληλη, θα πρέπει να εμφανίζεται όπως A.B.C.D
|
||||
|
||||
@ -7,10 +7,7 @@ package net.azib.ipscan.config;
|
||||
|
||||
import net.azib.ipscan.core.PluginLoader;
|
||||
import net.azib.ipscan.di.Injector;
|
||||
import net.azib.ipscan.exporters.CSVExporter;
|
||||
import net.azib.ipscan.exporters.IPListExporter;
|
||||
import net.azib.ipscan.exporters.TXTExporter;
|
||||
import net.azib.ipscan.exporters.XMLExporter;
|
||||
import net.azib.ipscan.exporters.*;
|
||||
import net.azib.ipscan.fetchers.*;
|
||||
|
||||
/**
|
||||
@ -25,7 +22,7 @@ public class ComponentRegistry {
|
||||
(Platform.WINDOWS ? ".WinMACFetcher" : Platform.LINUX ? ".LinuxMACFetcher" : ".UnixMACFetcher")).newInstance());
|
||||
i.register(CommentFetcher.class, FilteredPortsFetcher.class, WebDetectFetcher.class, HTTPSenderFetcher.class,
|
||||
NetBIOSInfoFetcher.class, PacketLossFetcher.class, HTTPProxyFetcher.class, MACVendorFetcher.class);
|
||||
i.register(TXTExporter.class, CSVExporter.class, XMLExporter.class, IPListExporter.class);
|
||||
i.register(TXTExporter.class, CSVExporter.class, XMLExporter.class, IPListExporter.class, SQLExporter.class);
|
||||
}
|
||||
|
||||
public Injector init() throws Exception {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package net.azib.ipscan.exporters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* SQL Exporter
|
||||
@ -14,7 +15,9 @@ import java.io.IOException;
|
||||
public class SQLExporter extends AbstractExporter {
|
||||
|
||||
static final char DELIMETER = ':';
|
||||
|
||||
static final String TABLE_NAME = "scan";
|
||||
static final char COMMA = ',';
|
||||
|
||||
public String getId() {
|
||||
return "exporter.sql";
|
||||
}
|
||||
@ -22,11 +25,37 @@ public class SQLExporter extends AbstractExporter {
|
||||
public String getFilenameExtension() {
|
||||
return "sql";
|
||||
}
|
||||
|
||||
|
||||
public void start(OutputStream outputStream, String feederInfo) throws IOException {
|
||||
super.start(outputStream, feederInfo);
|
||||
|
||||
if (!append) {
|
||||
output.println("DROP TABLE IF EXISTS scan;");
|
||||
}
|
||||
}
|
||||
|
||||
public void setFetchers(String[] fetcherNames) throws IOException {
|
||||
if (!append) {
|
||||
output.write("CREATE TABLE " + TABLE_NAME + " (`" + fetcherNames[0] + "` varchar(20)");
|
||||
for (int i = 1; i < fetcherNames.length; i++) {
|
||||
output.write(COMMA);
|
||||
output.print(" `" + fetcherNames[i] + "` ");
|
||||
output.write("varchar(20)"); //Default type
|
||||
}
|
||||
output.println(");");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void nextAddressResults(Object[] results) throws IOException {
|
||||
|
||||
output.print("INSERT INTO " + TABLE_NAME + " VALUES ('" + results[0]+"'");
|
||||
for (int i = 1; i < results.length; i++) {
|
||||
Object result = results[i];
|
||||
output.print(COMMA);
|
||||
output.print(" ");
|
||||
output.print("'" + result + "'");
|
||||
}
|
||||
output.println(");");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user