Skip to content

Commit

Permalink
Fixed Port Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Summitt committed Jul 12, 2023
1 parent 961039e commit 2a22357
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
18 changes: 12 additions & 6 deletions NonHTTPProxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-core</artifactId>
<version>1.8.2</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-packetfactory-static</artifactId>
<version>1.8.2</version>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -144,10 +144,16 @@
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
<version>3.3.0</version>
</dependency>
<groupId>dnsjava</groupId>
<artifactId>dnsjava</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.13.0</version>
</dependency>

</dependencies>
<name>NonHttp Burp Extension</name>
<url>http://github.com/summitt/</url>
Expand Down
2 changes: 1 addition & 1 deletion NonHTTPProxy/src/josh/nonHttp/GenericUDPMiTMServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void run() {



byte[] buffer = new byte[1024];
byte[] buffer = new byte[2056];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);


Expand Down
3 changes: 2 additions & 1 deletion NonHTTPProxy/src/josh/ui/NonHttpUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2759,7 +2759,8 @@ public void NewDomainRequest(DNSTableEvent e) {
String Domain = e.getDomain();
String ClientIp = e.getClientIP();
Vector<Object> vec = new Vector<Object>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd hh:mm:ss");
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd hh:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
vec.add(sdf.format(new Date()));
vec.add(Domain);
vec.add(e.getResponseIp());
Expand Down
3 changes: 2 additions & 1 deletion NonHTTPProxy/src/josh/ui/utils/NonHTTPTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public Class<?> getColumnClass(int columnIndex)
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss dd MMM yy");
//SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss dd MMM yy");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if(log.size() != 0){
LogEntry logEntry = log.get(rowIndex);

Expand Down
10 changes: 8 additions & 2 deletions NonHTTPProxy/src/josh/utils/Lister.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public void run() {
System.out.println("###############");
System.out.println(addr);
PcapNetworkInterface nif = Pcaps.getDevByAddress(addr);

if (nif == null) {
return;
System.out.println("No Interface Matches IP");
return;
}
handle
= nif.openLive(65536, PromiscuousMode.PROMISCUOUS, 10);
Expand All @@ -76,10 +78,13 @@ public void run() {
@Override
public void gotPacket(Packet packet) {
TcpPacket tcp = packet.get(TcpPacket.class);
System.out.println(tcp);
IpV4Packet ip = packet.get(IpV4Packet.class);
System.out.println(ip);
if(tcp == null || ip == null) return;
System.out.println("got a packet");
if(tcp.getHeader().getSyn() && !tcp.getHeader().getAck() ){ //&& !ip.getHeader().getSrcAddr().toString().equals("/"+IP)){
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd:hh:mm");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
String time = sdf.format(new Date());
String key = ip.getHeader().getSrcAddr().getHostAddress() + ":"+ tcp.getHeader().getDstPort().valueAsInt();
if(portsFound.containsKey(key) && portsFound.get(key).equals(time))
Expand All @@ -95,6 +100,7 @@ public void gotPacket(Packet packet) {
};

try {
System.out.println("Lister Started");
pool = Executors.newCachedThreadPool();
handle.loop(-1, listener, pool); // This is better than handle.loop(5, listener);
pool.shutdown();
Expand Down

0 comments on commit 2a22357

Please sign in to comment.