-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
050727f
commit e714259
Showing
7 changed files
with
561 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
OpenSOC-Alerts/src/main/java/com/opensoc/alerts/adapters/RangeChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.opensoc.alerts.adapters; | ||
|
||
import java.util.Set; | ||
|
||
import org.apache.commons.net.util.SubnetUtils; | ||
|
||
public class RangeChecker { | ||
|
||
static boolean checkRange(Set<String> CIDR_networks, String ip) { | ||
boolean in_range = false; | ||
try { | ||
for (String network : CIDR_networks) { | ||
|
||
System.out.println("Looking at range: " + network + " and ip " + ip); | ||
SubnetUtils utils = new SubnetUtils(network); | ||
in_range = utils.getInfo().isInRange(ip); | ||
|
||
if (!in_range) | ||
return false; | ||
} | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.