use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.
the class ConnectionUtil method getSource.
public String getSource(String url, boolean lineFeed) throws IOException {
Map<Header, Object> msgHeader = new EnumMap<>(Header.class);
msgHeader.put(Header.URL, url);
String pageSource = StringUtils.EMPTY;
try {
var httpRequest = HttpRequest.newBuilder().uri(URI.create(url)).timeout(Duration.ofSeconds(this.getTimeout())).build();
HttpHeaders httpHeaders;
if (lineFeed) {
HttpResponse<Stream<String>> response = this.getHttpClient().send(httpRequest, BodyHandlers.ofLines());
pageSource = response.body().collect(Collectors.joining("\n"));
httpHeaders = response.headers();
} else {
HttpResponse<String> response = this.getHttpClient().send(httpRequest, BodyHandlers.ofString());
pageSource = response.body();
httpHeaders = response.headers();
}
msgHeader.put(Header.RESPONSE, ConnectionUtil.getHeadersMap(httpHeaders));
msgHeader.put(Header.HEADER, ConnectionUtil.getHeadersMap(httpRequest.headers()));
} catch (IOException e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
} catch (InterruptedException e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
Thread.currentThread().interrupt();
} finally {
msgHeader.put(Header.SOURCE, pageSource);
// Inform the view about the log infos
var request = new Request();
request.setMessage(Interaction.MESSAGE_HEADER);
request.setParameters(msgHeader);
this.injectionModel.sendToViews(request);
}
return pageSource.trim();
}
use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.
the class StrategyInjectionTime method checkApplicability.
@Override
public void checkApplicability() throws StoppedByUserSlidingException {
if (StringUtils.isEmpty(this.injectionModel.getMediatorVendor().getVendor().instance().sqlBooleanTime())) {
LOGGER.log(LogLevel.CONSOLE_INFORM, "No Time strategy known for {}", this.injectionModel.getMediatorVendor().getVendor());
} else {
LOGGER.log(LogLevel.CONSOLE_DEFAULT, "{} Time with AND...", () -> I18nUtil.valueByKey("LOG_CHECKING_STRATEGY"));
this.injectionTime = new InjectionTime(this.injectionModel, BooleanMode.AND);
this.isApplicable = this.injectionTime.isInjectable();
if (!this.isApplicable) {
LOGGER.log(LogLevel.CONSOLE_DEFAULT, "{} Time with OR...", () -> I18nUtil.valueByKey("LOG_CHECKING_STRATEGY"));
this.injectionTime = new InjectionTime(this.injectionModel, BooleanMode.OR);
this.isApplicable = this.injectionTime.isInjectable();
if (this.isApplicable) {
LOGGER.log(LogLevel.CONSOLE_SUCCESS, "{} Time injection with OR", () -> I18nUtil.valueByKey("LOG_VULNERABLE"));
}
} else {
LOGGER.log(LogLevel.CONSOLE_SUCCESS, "{} Time injection with AND", () -> I18nUtil.valueByKey("LOG_VULNERABLE"));
}
if (this.isApplicable) {
this.allow();
var requestMessageBinary = new Request();
requestMessageBinary.setMessage(Interaction.MESSAGE_BINARY);
requestMessageBinary.setParameters(this.injectionTime.getInfoMessage());
this.injectionModel.sendToViews(requestMessageBinary);
} else {
this.unallow();
}
}
}
Aggregations