Compare commits

..

1 Commits

Author SHA1 Message Date
Carlos Polop
08c4c6fc1d Fix PR author detection for failure dispatch 2026-01-19 00:05:31 +01:00
5 changed files with 29 additions and 27 deletions

View File

@@ -26,15 +26,26 @@ jobs:
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: | run: |
pr_author=$(gh api -H "Accept: application/vnd.github+json" \ pr_json=$(gh api -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/pulls/${PR_NUMBER} \ /repos/${{ github.repository }}/pulls/${PR_NUMBER})
--jq '.user.login') pr_author=$(printf "%s" "$pr_json" | python3 - <<'PY'
pr_head_repo=$(gh api -H "Accept: application/vnd.github+json" \ import json,sys
/repos/${{ github.repository }}/pulls/${PR_NUMBER} \ data=json.load(sys.stdin)
--jq '.head.repo.full_name') print(data.get("user",{}).get("login",""))
pr_head_branch=$(gh api -H "Accept: application/vnd.github+json" \ PY
/repos/${{ github.repository }}/pulls/${PR_NUMBER} \ )
--jq '.head.ref') pr_head_repo=$(printf "%s" "$pr_json" | python3 - <<'PY'
import json,sys
data=json.load(sys.stdin)
print(data.get("head",{}).get("repo",{}).get("full_name",""))
PY
)
pr_head_branch=$(printf "%s" "$pr_json" | python3 - <<'PY'
import json,sys
data=json.load(sys.stdin)
print(data.get("head",{}).get("ref",""))
PY
)
{ {
echo "number=${PR_NUMBER}" echo "number=${PR_NUMBER}"
echo "author=${pr_author}" echo "author=${pr_author}"

View File

@@ -17,10 +17,10 @@ check_external_hostname(){
INTERNET_SEARCH_TIMEOUT=15 INTERNET_SEARCH_TIMEOUT=15
# wget or curl? # wget or curl?
if command -v curl >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1; then
curl "https://tools.hacktricks.wiki/api/host-checker" -H "User-Agent: linpeas" -d "{\"hostname\":\"$(hostname)\"}" -H "Content-Type: application/json" --max-time "$INTERNET_SEARCH_TIMEOUT" curl "https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/" -H "User-Agent: linpeas" -d "{\"hostname\":\"$(hostname)\"}" -H "Content-Type: application/json" --max-time "$INTERNET_SEARCH_TIMEOUT"
elif command -v wget >/dev/null 2>&1; then elif command -v wget >/dev/null 2>&1; then
wget -q -O - "https://tools.hacktricks.wiki/api/host-checker" --header "User-Agent: linpeas" --post-data "{\"hostname\":\"$(hostname)\"}" -H "Content-Type: application/json" --timeout "$INTERNET_SEARCH_TIMEOUT" wget -q -O - "https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/" --header "User-Agent: linpeas" --post-data "{\"hostname\":\"$(hostname)\"}" -H "Content-Type: application/json" --timeout "$INTERNET_SEARCH_TIMEOUT"
else else
echo "wget or curl not found" echo "wget or curl not found"
fi fi
} }

View File

@@ -15,12 +15,11 @@
check_tcp_443_bin () { check_tcp_443_bin () {
local TIMEOUT_INTERNET_SECONDS_443_BIN=$1 local TIMEOUT_INTERNET_SECONDS_443_BIN=$1
local url_lambda="https://tools.hacktricks.wiki/api/host-checker" local url_lambda="https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/"
if command -v curl >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1; then
if curl -s --connect-timeout $TIMEOUT_INTERNET_SECONDS_443_BIN "$url_lambda" \ if curl -s --connect-timeout $TIMEOUT_INTERNET_SECONDS_443_BIN "$url_lambda" \
-H "User-Agent: linpeas" -H "Content-Type: application/json" \ -H "User-Agent: linpeas" -H "Content-Type: application/json" >/dev/null 2>&1
-d "{\"hostname\":\"$(hostname)\"}" >/dev/null 2>&1
then then
echo "Port 443 is accessible with curl" echo "Port 443 is accessible with curl"
return 0 # ✅ success return 0 # ✅ success
@@ -31,8 +30,7 @@ check_tcp_443_bin () {
elif command -v wget >/dev/null 2>&1; then elif command -v wget >/dev/null 2>&1; then
if wget -q --timeout=$TIMEOUT_INTERNET_SECONDS_443_BIN -O - "$url_lambda" \ if wget -q --timeout=$TIMEOUT_INTERNET_SECONDS_443_BIN -O - "$url_lambda" \
--header "User-Agent: linpeas" -H "Content-Type: application/json" \ --header "User-Agent: linpeas" -H "Content-Type: application/json" >/dev/null 2>&1
--post-data "{\"hostname\":\"$(hostname)\"}" >/dev/null 2>&1
then then
echo "Port 443 is accessible with wget" echo "Port 443 is accessible with wget"
return 0 return 0

View File

@@ -46,7 +46,7 @@ namespace winPEAS.Info.NetworkInfo
// 4. Call external checker // 4. Call external checker
var resp = httpClient var resp = httpClient
.PostAsync("https://tools.hacktricks.wiki/api/host-checker", payload) .PostAsync("https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/", payload)
.GetAwaiter().GetResult(); .GetAwaiter().GetResult();
if (resp.IsSuccessStatusCode) if (resp.IsSuccessStatusCode)

View File

@@ -4,8 +4,6 @@ using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text;
using System.Text.Json;
using System.Threading; using System.Threading;
namespace winPEAS.Info.NetworkInfo namespace winPEAS.Info.NetworkInfo
@@ -50,7 +48,7 @@ namespace winPEAS.Info.NetworkInfo
{ "1.1.1.1", "8.8.8.8" }; { "1.1.1.1", "8.8.8.8" };
private const string LAMBDA_URL = private const string LAMBDA_URL =
"https://tools.hacktricks.wiki/api/host-checker"; "https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/";
// Shared HttpClient (kept for HTTP & Lambda checks) // Shared HttpClient (kept for HTTP & Lambda checks)
private static readonly HttpClient http = new HttpClient private static readonly HttpClient http = new HttpClient
@@ -120,12 +118,7 @@ namespace winPEAS.Info.NetworkInfo
using var cts = using var cts =
new CancellationTokenSource(TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS)); new CancellationTokenSource(TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS));
var payload = new StringContent( var req = new HttpRequestMessage(HttpMethod.Get, LAMBDA_URL);
JsonSerializer.Serialize(new { hostname = Environment.MachineName }),
Encoding.UTF8,
"application/json");
var req = new HttpRequestMessage(HttpMethod.Post, LAMBDA_URL);
req.Content = payload;
req.Headers.UserAgent.ParseAdd("winpeas"); req.Headers.UserAgent.ParseAdd("winpeas");
req.Headers.Accept.Add( req.Headers.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json")); new MediaTypeWithQualityHeaderValue("application/json"));