Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .vscode/tasks.json

This file was deleted.

Binary file added HostsLoader-1.0.0.jar
Binary file not shown.
Binary file removed HostsLoader-all.jar
Binary file not shown.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Hosts Loader

Burp plugin to automatically load hosts from /etc/hosts (or the Windows equivalent) into Burp's project hostname resolution override.
Supports adding custom dns hosts from dnsmasq on Linux.(`address=/custom1.tld/custom2.tld/custom3.tld/.../10.10.10.10`)

## Why?

When I'm doing HackTheBox, changing my /etc/hosts doesn't seem to work for resolving things in Burp Suite. I assume they're cached in some way, but honestly it was quicker to write this then debug why this happens.
When I'm doing HackTheBox or Vulnlab, changing my /etc/hosts (or the Windows equivalent or dnsmasq) doesn't seem to work (or I forget to reload dnsmasq) for resolving things in Burp Suite. I assume they're cached in some way, but honestly it was quicker to write this than try to debug why this happens.

## How to use

Install the jar as you would any other extension. A new tab will appear, click reload, and hosts will be loaded.
Install the jar as you would any other extension. A new tab will appear, click reload, and hosts will be loaded.

![Hosts Loader tab](img/example.png)
![Hosts Loader tab](img/example.png)

![Updated BurpSuite Setting](img/example2.png)

## How to build from source

### On Linux:

Run `gradlew build --project-cache-dir=/tmp/cache/.gradle/`

### On Windows:

Run `gradlew.bat build --project-cache-dir=%localappdata%\Temp\cache\.gradle\`
63 changes: 34 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.6/samples
*/
plugins {
id 'java'
}

// Apply the Java plugin
apply plugin: 'java'
version = '1.0.0'

// Use Maven (because Burp Extender is on Maven)
repositories {
mavenCentral()
mavenCentral()
}

dependencies {
// Add the Burp Extender interface
implementation 'net.portswigger.burp.extender:burp-extender-api:2.3'
compile 'com.google.guava:guava:31.1-jre'
compile 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
implementation 'net.portswigger.burp.extensions:montoya-api:+'
implementation 'com.google.guava:guava:33.3.0-jre'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

sourceSets {
main {
java {
// Set the source directory to "src"
srcDir 'src'
}
jar {
manifest {
attributes(
'Manifest-Version': '1.0',
'Created-By': 'Gradle 8.1.0',
'Main-Class': 'burp.HostsLoader'
)
}

from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}

duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

// Create a task for bundling all dependencies into a jar file.
task bigJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
task copyJar(type: Copy) {
dependsOn jar
from jar.archiveFile
into "${projectDir}"
}

task copyJar(type: Copy, dependsOn: bigJar) {
from(bigJar.archiveFile)
into project.rootProject.projectDir
}
build.finalizedBy(copyJar)
10 changes: 10 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
guava = "33.2.1-jre"
junit-jupiter = "5.10.3"

[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
34 changes: 21 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,10 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Loading