Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing Java with asdf #360

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion sources/assets/desktop/applications/burpsuite.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Burpsuite
Comment=Web pentest proxy and audit tool
Exec=/usr/lib/jvm/java-21-openjdk/bin/java -jar -Xmx4g /opt/tools/BurpSuiteCommunity/BurpSuiteCommunity.jar
Exec=java -jar -Xmx4g /opt/tools/BurpSuiteCommunity/BurpSuiteCommunity.jar
Icon=/usr/share/icons/Papirus/16x16/apps/kali-burpsuite.svg
Terminal=false
Type=Application
Expand Down
2 changes: 1 addition & 1 deletion sources/assets/desktop/applications/ghidra.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Name=Ghidra
Comment=Decompiler
Exec=bash -c "JAVA_HOME=/usr/lib/jvm/java-11-openjdk /opt/tools/ghidra_10.1.2_PUBLIC/ghidraRun"
Exec=bash -c "/opt/tools/ghidra_10.1.2_PUBLIC/ghidraRun"
Icon=/opt/tools/ghidra_10.1.2_PUBLIC/docs/images/GHIDRA_1.png
Terminal=false
Type=Application
Expand Down
2 changes: 1 addition & 1 deletion sources/assets/shells/aliases.d/burpsuite
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
alias BurpSuiteCommunity='/usr/lib/jvm/java-21-openjdk/bin/java -jar -Xmx4g /opt/tools/BurpSuiteCommunity/BurpSuiteCommunity.jar'
function BurpSuiteCommunity { (cd /opt/tools/BurpSuiteCommunity && java -jar -Xmx4g ./BurpSuiteCommunity.jar "$@") }
alias burpsuite=BurpSuiteCommunity
2 changes: 1 addition & 1 deletion sources/assets/shells/aliases.d/ghidra
Original file line number Diff line number Diff line change
@@ -1 +1 @@
alias ghidra='JAVA_HOME=/usr/lib/jvm/java-11-openjdk /opt/tools/ghidra_10.1.2_PUBLIC/ghidraRun'
alias ghidra='/opt/tools/ghidra_10.1.2_PUBLIC/ghidraRun'
6 changes: 3 additions & 3 deletions sources/assets/shells/aliases.d/neo4j
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alias neo4j="JAVA_HOME=/usr/lib/jvm/java-11-openjdk neo4j"
alias neo4j-admin="JAVA_HOME=/usr/lib/jvm/java-11-openjdk neo4j-admin"
alias neo4j-import="JAVA_HOME=/usr/lib/jvm/java-11-openjdk neo4j-import"
alias neo4j="JAVA_HOME=/root/.asdf/installs/java/adoptopenjdk-11.0.0+28 neo4j"
alias neo4j-admin="JAVA_HOME=/root/.asdf/installs/java/adoptopenjdk-11.0.0+28 neo4j-admin"
alias neo4j-import="JAVA_HOME=/root/.asdf/installs/java/adoptopenjdk-11.0.0+28 neo4j-import"
2 changes: 1 addition & 1 deletion sources/assets/shells/aliases.d/ysoserial
Original file line number Diff line number Diff line change
@@ -1 +1 @@
alias ysoserial='/usr/lib/jvm/java-11-openjdk/bin/java --add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.runtime=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED -jar /opt/tools/ysoserial/ysoserial.jar'
function ysoserial { (cd /opt/tools/ysoserial && java --add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.runtime=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED -jar -Xmx4g ./ysoserial.jar "$@") }
98 changes: 18 additions & 80 deletions sources/install/package_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,14 @@ function filesystem() {
function install_go() {
# CODE-CHECK-WHITELIST=add-aliases,add-to-list,add-history
colorecho "Installing go (Golang)"
asdf plugin add golang https://github.com/asdf-community/asdf-golang.git
asdf plugin add golang
# 1.19 needed by sliver
asdf install golang 1.19
#asdf install golang latest
#asdf global golang latest
# 1.23 needed by BloodHound-CE
asdf install golang 1.23.0
# With golang 1.23 many package build are broken, temp fix to use 1.22.2 as golang latest
local temp_fix_limit="2024-11-01"
if [[ "$(date +%Y%m%d)" -gt "$(date -d $temp_fix_limit +%Y%m%d)" ]]; then
criticalecho "Temp fix expired. Exiting."
else
# 1.23 needed by BloodHound-CE
asdf install golang 1.23.0
# Default GO version: 1.22.2
asdf install golang 1.22.2
asdf global golang 1.22.2
fi

# if command -v /usr/local/go/bin/go &>/dev/null; then
# return
# fi
# cd /tmp/ || exit
# if [[ $(uname -m) = 'x86_64' ]]
# then
# wget -O /tmp/go.tar.gz https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
# elif [[ $(uname -m) = 'aarch64' ]]
# then
# wget -O /tmp/go.tar.gz https://go.dev/dl/go1.21.5.linux-arm64.tar.gz
# elif [[ $(uname -m) = 'armv7l' ]]
# then
# wget -O /tmp/go.tar.gz https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz
# else
# criticalecho-noexit "This installation function doesn't support architecture $(uname -m)" && return
# fi
# rm -rf /usr/local/go
# tar -C /usr/local -xzf /tmp/go.tar.gz
# rm -rf /tmp/go.tar.gz
# export PATH=$PATH:/usr/local/go/bin
asdf install golang 1.22.2
asdf global golang 1.22.2
add-test-command "go version"
}

Expand Down Expand Up @@ -320,45 +291,18 @@ function install_gf() {
add-to-list "gf,https://github.com/tomnomnom/gf,A wrapper around grep to avoid typing common patterns"
}

function install_java11() {
# CODE-CHECK-WHITELIST=add-history,add-aliases,add-to-list
colorecho "Installing java 11"
if [[ $(uname -m) = 'x86_64' ]]
then
local arch="x64"

elif [[ $(uname -m) = 'aarch64' ]]
then
local arch="aarch64"
else
criticalecho-noexit "This installation function doesn't support architecture $(uname -m)" && return
fi
local jdk_url
jdk_url=$(curl --location --silent "https://api.github.com/repos/adoptium/temurin11-binaries/releases" | grep 'browser_download_url.*jdk_'"$arch"'_linux.*tar.gz"' | grep -o 'https://[^"]*' | sort | tail -n1)
curl --location -o /tmp/openjdk11-jdk.tar.gz "$jdk_url"
tar -xzf /tmp/openjdk11-jdk.tar.gz --directory /tmp
mkdir -p "/usr/lib/jvm"
mv /tmp/jdk-11* /usr/lib/jvm/java-11-openjdk
add-test-command "/usr/lib/jvm/java-11-openjdk/bin/java --version"
}

function install_java21() {
# CODE-CHECK-WHITELIST=add-history,add-aliases,add-to-list
colorecho "Installing java 11"
if [[ $(uname -m) = 'x86_64' ]]
then
wget -O /tmp/openjdk21-jdk.tar.gz "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz"

elif [[ $(uname -m) = 'aarch64' ]]
then
wget -O /tmp/openjdk21-jdk.tar.gz "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-aarch64_bin.tar.gz"
else
criticalecho-noexit "This installation function doesn't support architecture $(uname -m)" && return
fi
tar -xzf /tmp/openjdk21-jdk.tar.gz --directory /tmp
mkdir -p "/usr/lib/jvm"
mv /tmp/jdk-21* /usr/lib/jvm/java-21-openjdk
add-test-command "/usr/lib/jvm/java-21-openjdk/bin/java --version"
function install_java() {
# CODE-CHECK-WHITELIST=add-aliases,add-to-list,add-history
colorecho "Installing java"
asdf plugin-add java
# 11 needed by ysoserial
asdf install java adoptopenjdk-11.0.0+28
# 17 common
asdf install java openjdk-17.0.2
# 22 latest stable
asdf install java openjdk-22.0.1
asdf global java openjdk-22.0.1
add-test-command "java --version"
}

function add_debian_repository_components() {
Expand Down Expand Up @@ -492,13 +436,7 @@ function package_base() {
# Rust, Cargo, rvm
install_rust_cargo
install_rvm # Ruby Version Manager

# java11 install, and java17 as default
install_java11
install_java21
ln -s -v /usr/lib/jvm/java-17-openjdk-* /usr/lib/jvm/java-17-openjdk # To avoid determining the correct path based on the architecture
update-alternatives --set java /usr/lib/jvm/java-17-openjdk-*/bin/java # Set the default openjdk version to 17

install_java # Java language
install_go # Golang language
install_ohmyzsh # Awesome shell
install_fzf # Fuzzy finder
Expand Down
4 changes: 3 additions & 1 deletion sources/install/package_web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,11 @@ function install_ysoserial() {
colorecho "Installing ysoserial"
mkdir /opt/tools/ysoserial/
wget -O /opt/tools/ysoserial/ysoserial.jar "https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar"
asdf local java adoptopenjdk-11.0.0+28
add-aliases ysoserial
add-history ysoserial
add-test-command "ysoserial --help|& grep 'spring-core:4.1.4.RELEASE'"
add-test-command "ysoserial CommonsCollections4 'whoami'"
add-test-command "ysoserial CommonsCollections4 'whoami'|base64 -w0|grep 'rO0A'"
add-to-list "ysoserial,https://github.com/frohoff/ysoserial,A proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization."
}

Expand Down Expand Up @@ -781,6 +782,7 @@ function install_burpsuite() {
cp -v /root/sources/assets/burpsuite/trust-ca-burp.sh /opt/tools/BurpSuiteCommunity/
chmod +x /opt/tools/BurpSuiteCommunity/trust-ca-burp.sh
ln -v -s /opt/tools/BurpSuiteCommunity/trust-ca-burp.sh /opt/tools/bin/trust-ca-burp
asdf local java openjdk-22.0.1
add-aliases burpsuite
add-history burpsuite
add-test-command "which burpsuite"
Expand Down
Loading