Skip to content

Commit

Permalink
Fixed an issue with checksystem_response search, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pomo-mondreganto committed Aug 28, 2021
1 parent f65affd commit 44218b8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions client/spl_example_runme.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python3

# Exploit format and this example was adopted
# from the exploit farm by Alexander Bersenev (https://github.com/alexbers/exploit_farm).

import os
import random
import sys


# redis host is the same as farm host (usually, as farm starts redis server)
REDIS_HOST = 'put redis host here'
REDIS_HOST = os.getenv('REDIS_HOST', '127.0.0.1')
REDIS_PORT = 6378
REDIS_DB = 2

Expand All @@ -17,15 +13,20 @@

cache = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB)
except ImportError:
redis = None # suppress import warning
print('Redis is not installed, so you won\'t be able to use script caching')

if len(sys.argv) < 2:
print(f'Usage: {sys.argv[0]} <target>')
sys.exit(1)

ip = sys.argv[1]

print("Hello! I am a little sploit. I could be written on any language, but "
"my author loves Python. Look at my source - it is really simple. "
"I should steal flags and print them on stdout or stderr. ")

print("I need to attack a team with host `%s`." % sys.argv[1])
print(f"I need to attack a team with host `{ip}`.")

print("Here are some random flags for you:")

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
dockerfile: ./docker/server/Dockerfile
volumes:
- ./server/app:/app
- ./data:/data
- ./server/data:/data
environment:
- FARM_DATA=/data
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions server/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def get_filtered_flags():
if value:
conditions.append(('INSTR(LOWER({}), ?)'.format(column), value.lower()))

for param in ['time-since', 'time-until']:
for column in ['time-since', 'time-until']:
value = filters.get(column, '').strip()
if value:
timestamp = round(datetime.strptime(value, '%Y-%m-%d %H:%M').timestamp())
sign = '>=' if param == 'time-since' else '<='
sign = '>=' if column == 'time-since' else '<='
conditions.append(('time {} ?'.format(sign), timestamp))

page = int(filters.get('page', 1))
Expand Down
2 changes: 1 addition & 1 deletion server/front/src/components/FlagsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default {
status: this.status,
checksystem_response: this.checksystemResponse,
};
console.log("Flag filters", filters);
this.setFlagFilters(filters);
this.setSelectedPage(1);
await this.fetchFlags();
Expand Down
2 changes: 2 additions & 0 deletions server/front/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export default createStore({
} catch (e) {
console.error("Error fetching tasks", e);
}

await context.dispatch("fetchFilterOptions");
},

updatePage: async function (context, page) {
Expand Down
3 changes: 1 addition & 2 deletions server/front/src/views/Flags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import { mapActions } from "vuex";
import { flagsPerPage } from "@/config";
export default {
components: { FlagsForm, FlagsSubmit, FlagsTable },
methods: mapActions(["fetchFlags", "fetchFilterOptions"]),
methods: mapActions(["fetchFilterOptions"]),
created: async function () {
await this.fetchFilterOptions();
await this.fetchFlags({ page: 1, pageSize: flagsPerPage });
},
};
Expand Down

0 comments on commit 44218b8

Please sign in to comment.