fix linpeas not getting EC2 metadata
This commit is contained in:
parent
58c107df40
commit
ef28ef7a33
@ -16,14 +16,20 @@
|
||||
if [ "$is_aws_ec2" = "Yes" ]; then
|
||||
print_2title "AWS EC2 Enumeration"
|
||||
|
||||
HEADER="X-aws-ec2-metadata-token: "
|
||||
TOKEN=""
|
||||
TOKEN_HEADER="X-aws-ec2-metadata-token"
|
||||
TOKEN_TTL="X-aws-ec2-metadata-token-ttl-seconds: 21600"
|
||||
URL="http://169.254.169.254/latest/meta-data"
|
||||
|
||||
aws_req=""
|
||||
if [ "$(command -v curl || echo -n '')" ]; then
|
||||
aws_req="curl -s -f -L -H '$HEADER'"
|
||||
# Get token for IMDSv2
|
||||
TOKEN=$(curl -s -f -X PUT "http://169.254.169.254/latest/api/token" -H "$TOKEN_TTL" 2>/dev/null)
|
||||
aws_req="curl -s -f -L -H '$TOKEN_HEADER: $TOKEN'"
|
||||
elif [ "$(command -v wget || echo -n '')" ]; then
|
||||
aws_req="wget -q -O - --header '$HEADER'"
|
||||
# Get token for IMDSv2
|
||||
TOKEN=$(wget -q -O - --method=PUT --header="$TOKEN_TTL" "http://169.254.169.254/latest/api/token" 2>/dev/null)
|
||||
aws_req="wget -q -O - --header '$TOKEN_HEADER: $TOKEN'"
|
||||
else
|
||||
echo "Neither curl nor wget were found, I can't enumerate the metadata service :("
|
||||
fi
|
||||
|
@ -31,13 +31,10 @@ execBin() {
|
||||
|
||||
# ---------------- 120‑second wall‑clock timeout ----------------
|
||||
if command -v timeout >/dev/null 2>&1; then # GNU/BSD timeout
|
||||
print_info "Running $TOOL_NAME with 120s timeout"
|
||||
timeout --preserve-status -s 9 120 "$TMP_BIN" $PARAMS
|
||||
elif command -v gtimeout >/dev/null 2>&1; then # Homebrew coreutils (macOS)
|
||||
print_info "Running $TOOL_NAME with 120s gtimeout"
|
||||
gtimeout --preserve-status 120 "$TMP_BIN" $PARAMS
|
||||
gtimeout --preserve-status -s 9 120 "$TMP_BIN" $PARAMS
|
||||
else # POSIX fall‑back
|
||||
print_info "Running $TOOL_NAME with 120s custom timeout"
|
||||
(
|
||||
"$TMP_BIN" $PARAMS & # run in background
|
||||
cmdpid=$!
|
||||
|
Loading…
Reference in New Issue
Block a user