Skip to content

Commit

Permalink
install exploitfarm client also on server + filtering all import
Browse files Browse the repository at this point in the history
  • Loading branch information
domysh committed Jun 11, 2024
1 parent 9e99ad0 commit 3cd15e3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" backend/env.py;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" frontend/src/utils/env.ts;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" client/setup.py;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" client/exploitfarm/__init__.py;
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends libcapstone-dev
WORKDIR /execute
ADD ./backend/requirements.txt /execute/requirements.txt
RUN pip3 install --no-cache-dir --break-system-packages -r /execute/requirements.txt --no-warn-script-location
COPY ./client/ /tmp/client
RUN pip3 install --no-cache-dir --break-system-packages /tmp/client
COPY ./backend/ /execute/
COPY --from=frontend /build/dist/ ./frontend/

Expand Down
27 changes: 18 additions & 9 deletions client/exploitfarm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

from exploitfarm.utils import try_tcp_connection
from exploitfarm.model import ServiceDTO, AttackMode, SetupStatus
import requests, functools
import requests, functools, random, os
from exploitfarm.utils.config import ClientConfig
from exploitfarm.cmd.config import inital_config_setup
from exploitfarm.cmd.login import login_required

def get_host():
import os
result = os.getenv("XFARM_HOST", None)
if not result:
raise ValueError("this exploit has to be run with xfarm")
return result

def service_info() -> ServiceDTO|None:
import os
result = os.getenv("XFARM_SERVICE", None)
if not result:
return None
Expand All @@ -23,16 +24,12 @@ def service_info() -> ServiceDTO|None:
return None

def runtime_info() -> float:
import os
data = os.getenv("XFARM_RUNTIME", None)
if data is None:
raise ValueError("this exploit has to be run with xfarm")
return float(data)

def get_config():
from exploitfarm.utils.config import ClientConfig
from exploitfarm.cmd.config import inital_config_setup
from exploitfarm.cmd.login import login_required
config = ClientConfig.read()
if not inital_config_setup(config):
raise ValueError("It's required to setup the client first")
Expand All @@ -49,7 +46,6 @@ def random_str(
exclude:str = "",
include:str = ""
) -> str:
import random
alphabet = ""
if numbers: alphabet += "0123456789"
if lower: alphabet += "abcdefghijklmnopqrstuvwxyz"
Expand All @@ -69,7 +65,6 @@ def session(
additional_headers:list = [],
user_agent:str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.3",
) -> requests.Session:
import random
headers = {
"User-Agent": random.choice(
[
Expand All @@ -88,3 +83,17 @@ def session(

#Force flush print
print = functools.partial(print, flush = True)

#Exported functions
__all__ = [
"try_tcp_connection",
"AttackMode",
"SetupStatus",
"get_host",
"service_info",
"runtime_info",
"get_config",
"random_str",
"session",
"print",
]
1 change: 0 additions & 1 deletion client/exploitfarm/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from fasteners import InterProcessLock
import sys
import psutil
import logging

DEFAULT_SERVER_PORT = 5050

Expand Down
1 change: 0 additions & 1 deletion scripts/submitters/ccit_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FlagStatus:
'too old', 'not in database', 'already', 'invalid', 'nop team', 'game not started', 'try again later', 'game over', 'is not up', 'no such flag'],
}


def submit(flags, token:str = None, http_timeout:int=30, url:str="http://10.10.0.1:8080/flags"):
r = requests.put(url, headers={'X-Team-Token': token}, json=flags, timeout=http_timeout)
if r.status_code == 429:
Expand Down

0 comments on commit 3cd15e3

Please sign in to comment.