Skip to content

Commit

Permalink
Adding udp support (#68)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
summitt and Josh Summitt authored Oct 2, 2023
1 parent 9a6e39f commit b93b316
Show file tree
Hide file tree
Showing 19 changed files with 2,167 additions and 2,299 deletions.
4 changes: 0 additions & 4 deletions NonHTTPProxy/src/josh/dao/HibHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
public class HibHelper {




private static SessionFactory sessionFactory = buildSessionFactory();

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

prop.setProperty("hibernate.dialect", "josh.dao.SQLiteDialect");
//prop.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
prop.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
prop.setProperty("hibernate.show_sql", "false");
prop.setProperty("hibernate.hbm2ddl.auto", "update");
Expand Down
19 changes: 18 additions & 1 deletion NonHTTPProxy/src/josh/dao/ListenerSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ public class ListenerSetting {
private String cert;
@Column(name = "ssl")
private boolean ssl;
@Column(name = "udp")
private Boolean udp;

public ListenerSetting(){}

public ListenerSetting(int lport, int sport, String sip, String cert, boolean ssl){
public ListenerSetting(int lport, int sport, String sip, String cert, boolean ssl, Boolean udp){
this.lport = lport;
this.sport = sport;
this.sip = sip;
this.cert = cert;
this.ssl = ssl;
this.udp = udp;
}
public int getId() {
return id;
Expand Down Expand Up @@ -70,6 +73,20 @@ public boolean isSsl() {
public void setSsl(boolean ssl) {
this.ssl = ssl;
}
public Boolean isUdp() {
if(this.udp == null){
return false;
}else{
return udp;
}
}
public void setUdp(Boolean udp) {
if(udp == null){
this.udp = false;
}else{
this.udp = udp;
}
}


}
21 changes: 20 additions & 1 deletion NonHTTPProxy/src/josh/dao/Requests.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public class Requests {
private String data_str;
@Column(name = "original_str")
private String original_str;
@Column(name = "protocol")
private String protocol;


public Requests(){};

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


}
Expand Down Expand Up @@ -171,6 +174,22 @@ public String getOriginal_str() {
public void setOriginal_str(String original_str) {
this.original_str = original_str;
}

public String getProtocol(){
if(this.protocol == null){
return "TCP";
}else{
return this.protocol;
}
}

public void setProtocol(String protocol){
if(protocol == null){
this.protocol = "TCP";
}else{
this.protocol = protocol;
}
}



Expand Down
2 changes: 1 addition & 1 deletion NonHTTPProxy/src/josh/dao/UpdateDBTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void run() {
List<LogEntry> updated = new ArrayList<LogEntry>();
session.getTransaction().begin();
while((le = queue.poll())!= null){
Requests dao = new Requests(0, le.requestResponse, le.original, le.SrcIP, le.SrcPort, le.DstIP, le.DstPort, le.Direction, le.time.getTime(), le.Bytes);
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);
session.saveOrUpdate(dao);
le.Index =(long)dao.getId();
updated.add(le);
Expand Down
9 changes: 1 addition & 8 deletions NonHTTPProxy/src/josh/nonHttp/GenericMiTMServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,12 @@ public static boolean available(int port) {
}

ServerSocket ss = null;
DatagramSocket ds = null;
try {
ss = new ServerSocket(port);
ss.setReuseAddress(true);
ds = new DatagramSocket(port);
ds.setReuseAddress(true);
return true;
} catch (IOException e) {
} finally {
if (ds != null) {
ds.close();
}

if (ss != null) {
try {
ss.close();
Expand Down Expand Up @@ -169,7 +162,7 @@ public boolean isPythonOn() {
return this.MangleWithPython;
}

public void setPythonMange(boolean mangle) {
public void setPythonMangle(boolean mangle) {
this.MangleWithPython = mangle;
}

Expand Down
Loading

0 comments on commit b93b316

Please sign in to comment.