forked from p15670423/monkey
Agent: Fix linux command line for http request
This commit is contained in:
parent
babaadf286
commit
fe02e42ea0
|
@ -48,6 +48,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Create/check data directory on Island initialization. #1170
|
- Create/check data directory on Island initialization. #1170
|
||||||
- Format some log messages to make them more readable. #1283
|
- Format some log messages to make them more readable. #1283
|
||||||
- Improve runtime of some unit tests. #1125
|
- Improve runtime of some unit tests. #1125
|
||||||
|
- Run curl OR wget (not both) when attempting to communicate as a new user on
|
||||||
|
Linux. #1407
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Relevant dead code as reported by Vulture. #1149
|
- Relevant dead code as reported by Vulture. #1149
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
|
import shutil
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -64,11 +65,13 @@ class CommunicateAsNewUser(PBA):
|
||||||
'Invoke-WebRequest {url} -UseBasicParsing"'
|
'Invoke-WebRequest {url} -UseBasicParsing"'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# true || false -> 0. false || true -> 0. false || false -> 1. So:
|
|
||||||
# if curl works, we're good.
|
# if curl works, we're good.
|
||||||
# If curl doesn't exist or fails and wget work, we're good.
|
# If curl doesn't exist or fails and wget work, we're good.
|
||||||
# And if both don't exist: we'll call it a win.
|
# And if both don't exist: we'll call it a win.
|
||||||
format_string = "curl {url} || wget -O/dev/null -q {url}"
|
if shutil.which("curl") is not None:
|
||||||
|
format_string = "curl {url}"
|
||||||
|
else:
|
||||||
|
format_string = "wget -O/dev/null -q {url}"
|
||||||
return format_string.format(url=url)
|
return format_string.format(url=url)
|
||||||
|
|
||||||
def send_result_telemetry(self, exit_status, commandline, username):
|
def send_result_telemetry(self, exit_status, commandline, username):
|
||||||
|
|
Loading…
Reference in New Issue