Message Board

http:BL Use/Development

Older Posts ]   [ Newer Posts ]
 HttpBL.java, HttpBLDNSQueryResponse.java, Main.java
Author: M.Marrotte   (4 Sep 07 8:35am)
/*
* HttpBL.java
*
*/

package httpbl;
import java.net.InetAddress;

/**
*
* @author Mike Marrotte -- marrotte@gmail.com
*
*/
public class HttpBL {
private String accessKey = "";
private String listSpecificDomain = "";
private String visitorType = "";
private HttpBLDNSQueryResponse httpBLDNSQueryResponse = new HttpBLDNSQueryResponse();
private String[] ipArray = null;
private String octetReversedIP = "";
private String host = "";
private String response = "";
private String[] responseArray = null;

public HttpBL(String accessKey, String listSpecificDomain){
this.accessKey = accessKey;
this.listSpecificDomain = listSpecificDomain;
}

public HttpBLDNSQueryResponse getDNSQueryResponse(String ipAddress) throws Exception {
if (accessKey != "" && listSpecificDomain != "" && ipAddress != "") {
ipArray = ipAddress.split("\\.");
octetReversedIP = ipArray[3] + "." + ipArray[2] + "." + ipArray[1] + "." + ipArray[0];
host = accessKey + "." + octetReversedIP + "." + listSpecificDomain;
response = InetAddress.getByName(host).toString().split("/")[1];
responseArray = response.split("\\.");
httpBLDNSQueryResponse.setDaysLastActive(Integer.parseInt(responseArray[1]));
httpBLDNSQueryResponse.setThreatScore(Integer.parseInt(responseArray[2]));
httpBLDNSQueryResponse.setVisitorTypeCode(Integer.parseInt(responseArray[3]));
}
return httpBLDNSQueryResponse;
}
public void setAccessKey(String accessKey){this.accessKey = accessKey;}
public void setListSpecificDomain(String listSpecificDomain){this.listSpecificDomain = listSpecificDomain;}
}

/*
* DNSQueryResponse.java
*
*/

package httpbl;

/**
*
* @author Mike Marrotte -- marrotte@gmail.com
*
*/
public class HttpBLDNSQueryResponse {

private int daysLastActive = 0;
private int visitorTypeCode = 0;
private int threatScore = 0;
private String visitorType = "";
private String host = "";


public void setDaysLastActive(int daysLastActive){this.daysLastActive = daysLastActive;}
public void setVisitorTypeCode(int visitorTypeCode){this.visitorTypeCode = visitorTypeCode;}
public void setThreatScore(int threatScore){this.threatScore = threatScore;}

public int getDaysLastActive(){return daysLastActive;}
public int getVisitorTypeCode(){return visitorTypeCode;}
public int getThreatScore(){return threatScore;}
public String getVisitorType(){
switch (visitorTypeCode) {
case 0: visitorType = "Search Engine"; break;
case 1: visitorType = "Suspicious"; break;
case 2: visitorType = "Harvester"; break;
case 3: visitorType = "Suspicious & Harvester"; break;
case 4: visitorType = "Comment Spammer"; break;
case 5: visitorType = "Suspicious & Comment Spammer"; break;
case 6: visitorType = "Harvester & Comment Spammer"; break;
case 7: visitorType = "Suspicious & Harvester & Comment Spammer"; break;
default: visitorType = "Undefined"; break;
}
return visitorType;
}

}
/*
* Main.java
*
*/

package httpbl;
import java.net.InetAddress;

/**
*
* @author Mike Marrotte -- marrotte@gmail.com
*
*/

public class Main {
private static String accessKey = "[your access key goes here]";
private static String listSpecificDomain = "dnsbl.httpbl.org";
private static String ipAddress = "[some ip address goes here]";

public Main() {
}

public static void main(String[] args) throws Exception {

HttpBL httpBL = new HttpBL(accessKey, listSpecificDomain);
HttpBLDNSQueryResponse httpBLDNSQueryResponse = httpBL.getDNSQueryResponse(ipAddress);

System.out.println("Last Active: "+httpBLDNSQueryResponse.getDaysLastActive());
System.out.println("Threat Score: " + httpBLDNSQueryResponse.getThreatScore());
System.out.println("Visitor Type: "+ httpBLDNSQueryResponse.getVisitorType());
System.out.println("Visitor Type Code: " + httpBLDNSQueryResponse.getVisitorTypeCode());
}

}



do not follow this link

Privacy Policy | Terms of Use | About Project Honey Pot | FAQ | Cloudflare Site Protection | Contact Us

Copyright © 2004–17, Unspam Technologies, Inc. All rights reserved.

contact | wiki | email