Skip to content

Commit c4e643f

Browse files
authored
Update main.py
1 parent cdb1ca0 commit c4e643f

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

bin/pwnboard/main.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ def make_graphql_request(api_url, query, variables, cookies=None):
2424
def make_pwnboard_request(api_url, application_name, ips):
2525
data = {"ip": ips[0], "application": application_name}
2626
if len(ips) > 1:
27-
data["ips"] = ips[1:]
27+
data["ips"] = ips
2828
response = requests.post(api_url, json=data)
2929

3030
if response.status_code == 202:
3131
return True
3232
else:
33-
print(f"Error {response.status_code}: {response.text}")
33+
print(f"Pwnboard error {response.status_code}: {response.text}")
3434
return False
3535

3636

@@ -72,35 +72,37 @@ def make_pwnboard_request(api_url, application_name, ips):
7272

7373
graphql_query = """
7474
query pwnboard($input: HostWhereInput) {
75-
hosts(where: $input) {
76-
primaryIP
75+
hosts(where:$input) {
76+
edges {
77+
node {
78+
primaryIP
79+
}
80+
}
7781
}
78-
}
79-
"""
82+
}"""
8083
cookies = {
8184
"auth-session": auth_session,
8285
}
8386

8487
graphql_url = f"{args.tavern_url}/graphql"
8588

86-
pwnboard_url = f"{args.pwnboard_url}/pwn/boxaccess"
89+
pwnboard_url = f"{args.pwnboard_url}/boxaccess"
8790

8891
while True:
8992
current_time = datetime.utcnow()
9093

9194
time_five_minutes_ago = current_time - timedelta(seconds=args.timediff)
9295

9396
formatted_time = time_five_minutes_ago.strftime("%Y-%m-%dT%H:%M:%SZ")
94-
97+
print(formatted_time)
9598
graphql_variables = {"input": {"lastSeenAtGT": formatted_time}}
9699

97100
result = make_graphql_request(
98101
graphql_url, graphql_query, graphql_variables, cookies
99102
)
100-
101103
if result:
102104
if result["data"] and len(result["data"]["hosts"]) > 0:
103-
ips = list(map(lambda x: x["primaryIP"], result["data"]["hosts"]))
105+
ips = list(map(lambda x: x['node']["primaryIP"], result["data"]["hosts"]["edges"]))
104106
make_pwnboard_request(pwnboard_url, args.name, ips)
105107
else:
106108
print("No data found :(")

0 commit comments

Comments
 (0)