Skip to content

Commit b93b316

Browse files
summittJosh Summitt
andauthored
Adding udp support (#68)
* inital poorly working udp proxy * inital poorly working udp proxy * better upd proxy * better upd proxy * adding udp interceptor pipelines * adding udp interceptor pipelines * fixing broken UDP interceptor * fixing broken table when clearing all requests * adding better search features --------- Co-authored-by: Josh Summitt <ascetik@gamil.com>
1 parent 9a6e39f commit b93b316

19 files changed

Lines changed: 2167 additions & 2299 deletions

NonHTTPProxy/src/josh/dao/HibHelper.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
public class HibHelper {
1010

1111

12-
1312

1413
private static SessionFactory sessionFactory = buildSessionFactory();
1514

1615
private static SessionFactory buildSessionFactory() {
1716
System.out.println("Built new session factory");
18-
//java.util.logging.Logger.getLogger("org.hibernate").setLevel(java.util.logging.Level.OFF);
19-
//java.util.logging.Logger.getLogger("com.mchange").setLevel(java.util.logging.Level.OFF);
2017
try {
2118
String path = System.getProperty("user.home");
2219
String resultFile = path + "/.NoPEProxy/requests.sqlite";
@@ -25,7 +22,6 @@ private static SessionFactory buildSessionFactory() {
2522
Properties prop= new Properties();
2623

2724
prop.setProperty("hibernate.dialect", "josh.dao.SQLiteDialect");
28-
//prop.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
2925
prop.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
3026
prop.setProperty("hibernate.show_sql", "false");
3127
prop.setProperty("hibernate.hbm2ddl.auto", "update");

NonHTTPProxy/src/josh/dao/ListenerSetting.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ public class ListenerSetting {
2424
private String cert;
2525
@Column(name = "ssl")
2626
private boolean ssl;
27+
@Column(name = "udp")
28+
private Boolean udp;
2729

2830
public ListenerSetting(){}
2931

30-
public ListenerSetting(int lport, int sport, String sip, String cert, boolean ssl){
32+
public ListenerSetting(int lport, int sport, String sip, String cert, boolean ssl, Boolean udp){
3133
this.lport = lport;
3234
this.sport = sport;
3335
this.sip = sip;
3436
this.cert = cert;
3537
this.ssl = ssl;
38+
this.udp = udp;
3639
}
3740
public int getId() {
3841
return id;
@@ -70,6 +73,20 @@ public boolean isSsl() {
7073
public void setSsl(boolean ssl) {
7174
this.ssl = ssl;
7275
}
76+
public Boolean isUdp() {
77+
if(this.udp == null){
78+
return false;
79+
}else{
80+
return udp;
81+
}
82+
}
83+
public void setUdp(Boolean udp) {
84+
if(udp == null){
85+
this.udp = false;
86+
}else{
87+
this.udp = udp;
88+
}
89+
}
7390

7491

7592
}

NonHTTPProxy/src/josh/dao/Requests.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ public class Requests {
4040
private String data_str;
4141
@Column(name = "original_str")
4242
private String original_str;
43+
@Column(name = "protocol")
44+
private String protocol;
4345

4446

4547
public Requests(){};
4648

47-
public Requests(int Index, byte[] requestResponse, byte[] original, String SrcIp,int SrcPort, String DstIP, int DstPort, String Direction, Long time, int bytes){
49+
public Requests(int Index, byte[] requestResponse, byte[] original, String SrcIp,int SrcPort, String DstIP, int DstPort, String Direction, Long time, int bytes, String protocol){
4850
this.alt_id = Index;
4951
this.data = Base64.getEncoder().encodeToString(requestResponse);
5052
this.original = Base64.getEncoder().encodeToString(original);
@@ -57,6 +59,7 @@ public Requests(int Index, byte[] requestResponse, byte[] original, String SrcIp
5759
this.bytes = original.length;
5860
this.original_str = new String(original); //.replaceAll("[^a-zA-Z0-9~!@#$%^&*()_+`\\-=,./<>?\\s]", "");
5961
this.data_str = new String(requestResponse);//.replaceAll("[^a-zA-Z0-9~!@#$%^&*()_+`\\-=,./<>?\\s]", "");
62+
this.protocol = protocol;
6063

6164

6265
}
@@ -171,6 +174,22 @@ public String getOriginal_str() {
171174
public void setOriginal_str(String original_str) {
172175
this.original_str = original_str;
173176
}
177+
178+
public String getProtocol(){
179+
if(this.protocol == null){
180+
return "TCP";
181+
}else{
182+
return this.protocol;
183+
}
184+
}
185+
186+
public void setProtocol(String protocol){
187+
if(protocol == null){
188+
this.protocol = "TCP";
189+
}else{
190+
this.protocol = protocol;
191+
}
192+
}
174193

175194

176195

NonHTTPProxy/src/josh/dao/UpdateDBTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void run() {
5858
List<LogEntry> updated = new ArrayList<LogEntry>();
5959
session.getTransaction().begin();
6060
while((le = queue.poll())!= null){
61-
Requests dao = new Requests(0, le.requestResponse, le.original, le.SrcIP, le.SrcPort, le.DstIP, le.DstPort, le.Direction, le.time.getTime(), le.Bytes);
61+
Requests dao = new Requests(0, le.requestResponse, le.original, le.SrcIP, le.SrcPort, le.DstIP, le.DstPort, le.Direction, le.time.getTime(), le.Bytes, le.protocol);
6262
session.saveOrUpdate(dao);
6363
le.Index =(long)dao.getId();
6464
updated.add(le);

NonHTTPProxy/src/josh/nonHttp/GenericMiTMServer.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,12 @@ public static boolean available(int port) {
9696
}
9797

9898
ServerSocket ss = null;
99-
DatagramSocket ds = null;
10099
try {
101100
ss = new ServerSocket(port);
102101
ss.setReuseAddress(true);
103-
ds = new DatagramSocket(port);
104-
ds.setReuseAddress(true);
105102
return true;
106103
} catch (IOException e) {
107104
} finally {
108-
if (ds != null) {
109-
ds.close();
110-
}
111-
112105
if (ss != null) {
113106
try {
114107
ss.close();
@@ -169,7 +162,7 @@ public boolean isPythonOn() {
169162
return this.MangleWithPython;
170163
}
171164

172-
public void setPythonMange(boolean mangle) {
165+
public void setPythonMangle(boolean mangle) {
173166
this.MangleWithPython = mangle;
174167
}
175168

0 commit comments

Comments
 (0)