Skip to content

Commit

Permalink
new loki-client
Browse files Browse the repository at this point in the history
  • Loading branch information
c0m4r committed Jan 6, 2024
1 parent 183ee50 commit bc0dfb1
Showing 1 changed file with 40 additions and 21 deletions.
61 changes: 40 additions & 21 deletions loki-client.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
#!/usr/bin/env python3

# Usage: python3 loki_client.py test
#!/usr/bin/env python

import argparse
import os
import socket
import sys

host = "127.0.0.1"
port = 1337
# Parse Arguments
parser = argparse.ArgumentParser(
description="Loki - Client", formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("-p", help="Path to scan", metavar="PATH")
parser.add_argument(
"--host",
help="Target daemon host",
default="localhost",
)
parser.add_argument(
"--port",
help="Target daemon port",
default=1337,
)
parser.add_argument(
"--auth",
metavar="AUTHKEY",
help="Pass authkey if it is required",
)
parser.add_argument(
"--check",
action="store_true",
help="Check if path exists before it is sent",
default=False,
)

try:
path = sys.argv[1]
except Exception:
print("missing path")
sys.exit(1)
args = parser.parse_args()

try:
auth = sys.argv[2]
except Exception:
auth = ""
if not args.p:
print("Missing -p path")
sys.exit(1)

if not os.path.isfile(path) and not os.path.isdir(path):
print(path + " not found")
sys.exit(127)
if args.check:
if not os.path.isfile(args.p) and not os.path.isdir(args.p):
print(args.p + " not found")
sys.exit(1)

try:
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand All @@ -31,15 +50,15 @@
sys.exit(1)

try:
client.connect((host, port))
client.connect((args.host, int(args.port)))
except socket.error:
print("Could not connect to server")
sys.exit(1)

if auth:
data = sys.argv[1] + " " + sys.argv[2]
if args.auth:
data = args.p + " " + args.auth
else:
data = sys.argv[1]
data = args.p

client.send(data.encode())
message = client.recv(2048)
Expand Down

0 comments on commit bc0dfb1

Please sign in to comment.