feat(v1.4.0): major upgrade - AI module, Sec recon engine, thread concurrency, functional array methods, and binary builder
This commit is contained in:
1 parent
8a1ac0b814
commit
9b9dc4de6a
7 files changed
+706
-13
No files matched your search
@@ -168,3 +168,11 @@ class DictNode(ASTNode):
|
||||
def __init__(self, pairs, line):
|
||||
self.pairs = pairs
|
||||
self.line = line
|
||||
|
||||
class FunctionExprNode(ASTNode):
|
||||
def __init__(self, name, params, body, line):
|
||||
self.name = name
|
||||
self.params = params
|
||||
self.body = body
|
||||
self.line = line
|
||||
|
||||
+95
-6
@@ -8,7 +8,7 @@ from lexer import Lexer
|
||||
from parser import Parser
|
||||
from evaluator import Evaluator
|
||||
|
||||
VERSION = "1.3.0 (Pro Edition)"
|
||||
VERSION = "1.4.0 (Aira Cyber & AI Edition)"
|
||||
AUTHOR = "Adam Eehan (Aira Group of Technology)"
|
||||
|
||||
ASCII_BANNER = f"""\033[1;36m
|
||||
@@ -21,6 +21,7 @@ ASCII_BANNER = f"""\033[1;36m
|
||||
\033[0m\033[1;30m---------------------------------------------------\033[0m
|
||||
\033[1;32m[+]\033[0m \033[1;37mEngine:\033[0m AiraLang v{VERSION}
|
||||
\033[1;34m[*]\033[0m \033[1;37mCreator:\033[0m {AUTHOR}
|
||||
\033[1;35m[⚡]\033[0m \033[1;37mModules:\033[0m ai, sec, thread, sqlite, net, crypto
|
||||
\033[1;33m[!]\033[0m Multiline support: open \033[1;32m{{\033[0m will continue on next line.
|
||||
\033[1;33m[!]\033[0m Type \033[1;31m'exit'\033[0m or \033[1;31m'quit'\033[0m to close REPL.
|
||||
\033[1;30m---------------------------------------------------\033[0m
|
||||
@@ -144,15 +145,103 @@ def start_repl():
|
||||
print("\n\033[1;33m[*] Interrupted. Exiting AiraLang...\033[0m")
|
||||
break
|
||||
|
||||
def build_file(source_path, output_path=None):
|
||||
if not os.path.exists(source_path):
|
||||
print(f"\033[1;31m[!] Error: File '{source_path}' not found.\033[0m")
|
||||
sys.exit(1)
|
||||
if output_path is None:
|
||||
output_path = os.path.splitext(source_path)[0]
|
||||
with open(source_path, "r", encoding="utf-8") as f:
|
||||
aira_code = f.read()
|
||||
|
||||
runner_script = f"""#!/data/data/com.termux/files/usr/bin/python3
|
||||
# ==========================================
|
||||
# Standalone Binary Executable
|
||||
# Generated by AiraLang v{VERSION}
|
||||
# Author: {AUTHOR}
|
||||
# ==========================================
|
||||
import sys, os
|
||||
AIRA_SRC = "/data/data/com.termux/files/home/airalang/src"
|
||||
if AIRA_SRC not in sys.path:
|
||||
sys.path.insert(0, AIRA_SRC)
|
||||
from cli import run_code
|
||||
CODE = {repr(aira_code)}
|
||||
if __name__ == '__main__':
|
||||
run_code(CODE)
|
||||
"""
|
||||
with open(output_path, "w", encoding="utf-8") as f:
|
||||
f.write(runner_script)
|
||||
os.chmod(output_path, 0o755)
|
||||
print(f"\033[1;32m[+] Successfully built executable binary:\033[0m {output_path}")
|
||||
print(f"\033[1;34m[*] Run it directly:\033[0m ./{output_path}")
|
||||
|
||||
def new_project(proj_name):
|
||||
if os.path.exists(proj_name):
|
||||
print(f"\033[1;31m[!] Error: Directory '{proj_name}' already exists.\033[0m")
|
||||
return
|
||||
os.makedirs(proj_name, exist_ok=True)
|
||||
main_code = f"""# 🚀 Welcome to {proj_name}!
|
||||
# Powered by AiraLang v{VERSION}
|
||||
# Creator: {AUTHOR}
|
||||
|
||||
import "ai";
|
||||
import "sec";
|
||||
|
||||
say "🔥 Welcome to {proj_name} powered by AiraLang!";
|
||||
let creator = "{AUTHOR}";
|
||||
say "⚡ Built by: " + creator;
|
||||
"""
|
||||
with open(os.path.join(proj_name, "main.aira"), "w", encoding="utf-8") as f:
|
||||
f.write(main_code)
|
||||
with open(os.path.join(proj_name, "README.md"), "w", encoding="utf-8") as f:
|
||||
f.write(f"# {proj_name}\\n\\nProject created with AiraLang v{VERSION}.\\n\\nRun:\\n```bash\\nairalang main.aira\\n```\\n")
|
||||
print(f"\033[1;32m[+] Created new AiraLang project:\033[0m {proj_name}/")
|
||||
print(f"\033[1;34m[*] cd {proj_name} && airalang main.aira\033[0m")
|
||||
|
||||
def print_help():
|
||||
print(f"""\033[1;36mAiraLang v{VERSION}\033[0m
|
||||
Creator: {AUTHOR}
|
||||
|
||||
\033[1;33mUsage:\033[0m
|
||||
airalang Start interactive REPL
|
||||
airalang <script.aira> Execute an AiraLang script
|
||||
airalang run <script.aira> Execute an AiraLang script
|
||||
airalang build <file.aira> [-o out] Compile script to standalone executable
|
||||
airalang new <project_name> Create a new AiraLang project scaffold
|
||||
airalang -v, --version Display version information
|
||||
airalang -h, --help Show this help message
|
||||
""")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] in ("-v", "--version"):
|
||||
arg1 = sys.argv[1]
|
||||
if arg1 in ("-v", "--version"):
|
||||
print(f"AiraLang v{VERSION} | Creator: {AUTHOR}")
|
||||
elif sys.argv[1] in ("-h", "--help"):
|
||||
print("Usage: airalang [script.aira]")
|
||||
print(" airalang (starts interactive REPL)")
|
||||
elif arg1 in ("-h", "--help"):
|
||||
print_help()
|
||||
elif arg1 == "run":
|
||||
if len(sys.argv) > 2:
|
||||
run_file(sys.argv[2])
|
||||
else:
|
||||
print("\033[1;31m[!] Error: Specify file to run: airalang run <file.aira>\033[0m")
|
||||
elif arg1 == "build":
|
||||
if len(sys.argv) > 2:
|
||||
src_file = sys.argv[2]
|
||||
out_file = None
|
||||
if "-o" in sys.argv:
|
||||
idx = sys.argv.index("-o")
|
||||
if idx + 1 < len(sys.argv):
|
||||
out_file = sys.argv[idx + 1]
|
||||
build_file(src_file, out_file)
|
||||
else:
|
||||
print("\033[1;31m[!] Error: Specify file to build: airalang build <file.aira> [-o <out>]\033[0m")
|
||||
elif arg1 == "new":
|
||||
if len(sys.argv) > 2:
|
||||
new_project(sys.argv[2])
|
||||
else:
|
||||
print("\033[1;31m[!] Error: Specify project name: airalang new <project_name>\033[0m")
|
||||
else:
|
||||
run_file(sys.argv[1])
|
||||
run_file(arg1)
|
||||
else:
|
||||
start_repl()
|
||||
|
||||
|
||||
+73
-2
@@ -47,6 +47,9 @@ class AiraFunction:
|
||||
self.def_node = def_node
|
||||
self.closure_env = closure_env
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.call(Evaluator._current_evaluator, list(args))
|
||||
|
||||
def call(self, evaluator, args, this_instance=None):
|
||||
fn_env = Environment(parent=self.closure_env)
|
||||
if this_instance is not None:
|
||||
@@ -129,6 +132,10 @@ class Evaluator:
|
||||
self.global_env.set("bin", lambda x: bin(int(x)))
|
||||
self.global_env.set("ord", lambda c: ord(str(c)[0]))
|
||||
self.global_env.set("chr", lambda x: chr(int(x)))
|
||||
self.global_env.set("sorted", lambda lst, reverse=False: sorted(lst, reverse=bool(reverse)))
|
||||
self.global_env.set("reversed", lambda lst: list(reversed(lst)))
|
||||
self.global_env.set("enumerate", lambda lst: [[i, v] for i, v in enumerate(lst)])
|
||||
self.global_env.set("zip", lambda *lsts: [list(items) for items in zip(*lsts)])
|
||||
|
||||
def eval(self, ast):
|
||||
return self.eval_node(ast, self.global_env)
|
||||
@@ -309,6 +316,12 @@ class Evaluator:
|
||||
env.set(node.name, fn)
|
||||
return fn
|
||||
|
||||
elif nodetype == "FunctionExprNode":
|
||||
fn = AiraFunction(node, env)
|
||||
if node.name:
|
||||
env.set(node.name, fn)
|
||||
return fn
|
||||
|
||||
elif nodetype == "ReturnStatementNode":
|
||||
val = self.eval_node(node.expression, env) if node.expression else None
|
||||
raise ReturnException(val)
|
||||
@@ -351,6 +364,8 @@ class Evaluator:
|
||||
return target[member]
|
||||
if member == "keys": return lambda: list(target.keys())
|
||||
if member == "values": return lambda: list(target.values())
|
||||
if member == "items": return lambda: [[k, v] for k, v in target.items()]
|
||||
if member == "get": return lambda k, default=None: target.get(k, default)
|
||||
if member == "has" or member == "contains": return lambda k: k in target
|
||||
if member == "length": return len(target)
|
||||
|
||||
@@ -359,6 +374,7 @@ class Evaluator:
|
||||
if member == "length": return len(target)
|
||||
if member == "upper": return lambda: target.upper()
|
||||
if member == "lower": return lambda: target.lower()
|
||||
if member == "title": return lambda: target.title()
|
||||
if member == "split": return lambda sep=" ": target.split(sep)
|
||||
if member == "trim" or member == "strip": return lambda: target.strip()
|
||||
if member == "replace": return lambda old, new: target.replace(str(old), str(new))
|
||||
@@ -366,6 +382,8 @@ class Evaluator:
|
||||
if member == "starts_with" or member == "startswith": return lambda sub: target.startswith(str(sub))
|
||||
if member == "ends_with" or member == "endswith": return lambda sub: target.endswith(str(sub))
|
||||
if member == "slice": return lambda start, end=None: target[int(start):int(end) if end is not None else None]
|
||||
if member == "reverse": return lambda: target[::-1]
|
||||
if member == "count": return lambda sub: target.count(str(sub))
|
||||
|
||||
# List methods & properties
|
||||
elif isinstance(target, list):
|
||||
@@ -374,9 +392,62 @@ class Evaluator:
|
||||
if member == "pop": return lambda idx=-1: target.pop(idx)
|
||||
if member == "join": return lambda sep=" ": sep.join(str(x) for x in target)
|
||||
if member == "contains": return lambda x: x in target
|
||||
if member == "reverse": return lambda: target.reverse() or target
|
||||
if member == "sort": return lambda: target.sort() or target
|
||||
if member == "reverse": return lambda: list(reversed(target))
|
||||
if member == "sort": return lambda reverse=False: sorted(target, reverse=bool(reverse))
|
||||
if member == "slice": return lambda start, end=None: target[int(start):int(end) if end is not None else None]
|
||||
if member == "count": return lambda x: target.count(x)
|
||||
if member == "indexOf" or member == "find_index": return lambda x: target.index(x) if x in target else -1
|
||||
if member == "map":
|
||||
def _map(fn):
|
||||
res = []
|
||||
for x in target:
|
||||
val = fn.call(self, [x]) if isinstance(fn, AiraFunction) else fn(x)
|
||||
res.append(val)
|
||||
return res
|
||||
return _map
|
||||
if member == "filter":
|
||||
def _filter(fn):
|
||||
res = []
|
||||
for x in target:
|
||||
val = fn.call(self, [x]) if isinstance(fn, AiraFunction) else fn(x)
|
||||
if val:
|
||||
res.append(x)
|
||||
return res
|
||||
return _filter
|
||||
if member == "find":
|
||||
def _find(fn):
|
||||
for x in target:
|
||||
val = fn.call(self, [x]) if isinstance(fn, AiraFunction) else fn(x)
|
||||
if val:
|
||||
return x
|
||||
return None
|
||||
return _find
|
||||
if member == "each" or member == "forEach":
|
||||
def _each(fn):
|
||||
for x in target:
|
||||
if isinstance(fn, AiraFunction):
|
||||
fn.call(self, [x])
|
||||
else:
|
||||
fn(x)
|
||||
return target
|
||||
return _each
|
||||
if member == "reduce":
|
||||
def _reduce(fn, initial=None):
|
||||
items = list(target)
|
||||
if initial is None:
|
||||
if not items:
|
||||
raise ValueError("reduce on empty list with no initial value")
|
||||
accum = items[0]
|
||||
items = items[1:]
|
||||
else:
|
||||
accum = initial
|
||||
for x in items:
|
||||
if isinstance(fn, AiraFunction):
|
||||
accum = fn.call(self, [accum, x])
|
||||
else:
|
||||
accum = fn(accum, x)
|
||||
return accum
|
||||
return _reduce
|
||||
|
||||
elif hasattr(target, member):
|
||||
return getattr(target, member)
|
||||
|
||||
@@ -382,5 +382,18 @@ class Parser:
|
||||
pairs.append((k, v))
|
||||
self.expect("RBRACE")
|
||||
return DictNode(pairs, tok.line)
|
||||
if self.match("FN"):
|
||||
fn_name = None
|
||||
if self.current().type == "IDENTIFIER":
|
||||
fn_name = self.expect("IDENTIFIER").value
|
||||
self.expect("LPAREN")
|
||||
params = []
|
||||
if self.current().type != "RPAREN":
|
||||
params.append(self.expect("IDENTIFIER").value)
|
||||
while self.match("COMMA"):
|
||||
params.append(self.expect("IDENTIFIER").value)
|
||||
self.expect("RPAREN")
|
||||
body = self.parse_block_or_statement()
|
||||
return FunctionExprNode(fn_name, params, body, tok.line)
|
||||
|
||||
raise SyntaxError(f"AiraLang SyntaxError: Unexpected token '{tok.type}' ({repr(tok.value)}) at line {tok.line}, col {tok.col}")
|
||||
+318
-1
@@ -10,6 +10,8 @@ import socket
|
||||
import sqlite3
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
class AiraModule:
|
||||
def __init__(self, name, methods=None):
|
||||
@@ -227,6 +229,7 @@ def create_time_module():
|
||||
def create_json_module():
|
||||
return AiraModule("json", {
|
||||
"parse": lambda s: json.loads(s),
|
||||
"mkstring": lambda obj, indent=2: json.dumps(obj, indent=indent),
|
||||
"stringify": lambda obj, indent=2: json.dumps(obj, indent=indent)
|
||||
})
|
||||
|
||||
@@ -323,6 +326,316 @@ def create_string_module():
|
||||
"join": lambda lst, sep=" ": sep.join(str(x) for x in lst)
|
||||
})
|
||||
|
||||
def create_ai_module():
|
||||
state = {
|
||||
"gemini_key": os.environ.get("GEMINI_API_KEY", ""),
|
||||
"groq_key": os.environ.get("GROQ_API_KEY", "")
|
||||
}
|
||||
|
||||
def set_key(key, provider="gemini"):
|
||||
if str(provider).lower() == "groq":
|
||||
state["groq_key"] = str(key)
|
||||
else:
|
||||
state["gemini_key"] = str(key)
|
||||
return True
|
||||
|
||||
def get_key(provider="gemini"):
|
||||
return state["groq_key"] if str(provider).lower() == "groq" else state["gemini_key"]
|
||||
|
||||
def ask(prompt, model="gemini-2.5-flash", key=None):
|
||||
api_key = key or state["gemini_key"]
|
||||
if not api_key:
|
||||
if state["groq_key"]:
|
||||
return groq(prompt, key=state["groq_key"])
|
||||
return f"[Aira AI Engine] Notice: No API Key configured. Call `ai.set_key('YOUR_API_KEY')` or set `GEMINI_API_KEY` in environment. Received prompt: '{prompt}'"
|
||||
|
||||
url = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={api_key}"
|
||||
payload = json.dumps({"contents": [{"parts": [{"text": str(prompt)}]}]}).encode("utf-8")
|
||||
req = urllib.request.Request(url, data=payload, headers={"Content-Type": "application/json"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
data = json.loads(resp.read().decode("utf-8"))
|
||||
return data["candidates"][0]["content"]["parts"][0]["text"]
|
||||
except Exception as e:
|
||||
return f"[Aira AI Error]: {e}"
|
||||
|
||||
def groq(prompt, model="llama-3.3-70b-versatile", key=None):
|
||||
api_key = key or state["groq_key"]
|
||||
if not api_key:
|
||||
return f"[Aira Groq Error]: No GROQ API key provided. Set GROQ_API_KEY or call ai.set_key('key', 'groq')."
|
||||
url = "https://api.groq.com/openai/v1/chat/completions"
|
||||
payload = json.dumps({
|
||||
"model": model,
|
||||
"messages": [{"role": "user", "content": str(prompt)}]
|
||||
}).encode("utf-8")
|
||||
req = urllib.request.Request(url, data=payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {api_key}"
|
||||
})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
data = json.loads(resp.read().decode("utf-8"))
|
||||
return data["choices"][0]["message"]["content"]
|
||||
except Exception as e:
|
||||
return f"[Aira Groq Error]: {e}"
|
||||
|
||||
def chat(messages, model="gemini-2.5-flash", key=None):
|
||||
api_key = key or state["gemini_key"]
|
||||
if not api_key and state["groq_key"]:
|
||||
url = "https://api.groq.com/openai/v1/chat/completions"
|
||||
payload = json.dumps({"model": "llama-3.3-70b-versatile", "messages": messages}).encode("utf-8")
|
||||
req = urllib.request.Request(url, data=payload, headers={
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {state['groq_key']}"
|
||||
})
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
return json.loads(resp.read().decode("utf-8"))["choices"][0]["message"]["content"]
|
||||
last_msg = messages[-1]["content"] if isinstance(messages, list) and messages else str(messages)
|
||||
return ask(last_msg, model=model, key=api_key)
|
||||
|
||||
def summarize(text, max_words=100):
|
||||
prompt = f"Summarize the following text concisely in under {max_words} words:\n\n{text}"
|
||||
return ask(prompt)
|
||||
|
||||
return AiraModule("ai", {
|
||||
"ask": ask,
|
||||
"chat": chat,
|
||||
"groq": groq,
|
||||
"summarize": summarize,
|
||||
"set_key": set_key,
|
||||
"get_key": get_key,
|
||||
})
|
||||
|
||||
def create_sec_module():
|
||||
COMMON_SERVICES = {
|
||||
21: "FTP", 22: "SSH", 23: "Telnet", 25: "SMTP", 53: "DNS",
|
||||
80: "HTTP", 110: "POP3", 111: "RPCBind", 135: "RPC", 139: "NetBIOS",
|
||||
143: "IMAP", 443: "HTTPS", 445: "SMB", 993: "IMAPS", 995: "POP3S",
|
||||
1433: "MSSQL", 1521: "Oracle", 3306: "MySQL", 3389: "RDP",
|
||||
5432: "PostgreSQL", 5900: "VNC", 6379: "Redis", 8000: "HTTP-Alt",
|
||||
8080: "HTTP-Proxy", 8443: "HTTPS-Alt", 8888: "HTTP-Alt", 9000: "SonarQube",
|
||||
27017: "MongoDB"
|
||||
}
|
||||
|
||||
def scan_port(host, port, timeout=1.0):
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(float(timeout))
|
||||
res = s.connect_ex((str(host), int(port)))
|
||||
s.close()
|
||||
return res == 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def scan_ports(host, ports=None, threads=15, timeout=1.0):
|
||||
if ports is None:
|
||||
ports = [21, 22, 23, 25, 53, 80, 110, 143, 443, 445, 1433, 1521, 3306, 3389, 5432, 6379, 8000, 8080, 8443, 8888]
|
||||
elif isinstance(ports, range):
|
||||
ports = list(ports)
|
||||
elif not isinstance(ports, list):
|
||||
ports = [int(ports)]
|
||||
|
||||
open_ports = []
|
||||
def _check(p):
|
||||
if scan_port(host, p, timeout=timeout):
|
||||
svc = COMMON_SERVICES.get(p, "Unknown")
|
||||
return {"port": p, "service": svc, "state": "open"}
|
||||
return None
|
||||
|
||||
with ThreadPoolExecutor(max_workers=int(threads)) as executor:
|
||||
results = executor.map(_check, ports)
|
||||
for r in results:
|
||||
if r is not None:
|
||||
open_ports.append(r)
|
||||
return open_ports
|
||||
|
||||
def banner(host, port, timeout=2.0):
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(float(timeout))
|
||||
s.connect((str(host), int(port)))
|
||||
if int(port) in (80, 8080, 8000, 8888):
|
||||
s.sendall(b"HEAD / HTTP/1.0\r\n\r\n")
|
||||
else:
|
||||
s.sendall(b"\r\n")
|
||||
data = s.recv(1024).decode('utf-8', errors='ignore').strip()
|
||||
s.close()
|
||||
return data
|
||||
except Exception as e:
|
||||
return f"Error: {e}"
|
||||
|
||||
def audit_headers(url):
|
||||
if not str(url).startswith("http://") and not str(url).startswith("https://"):
|
||||
url = "https://" + str(url)
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "AiraLang-SecEngine/1.4.0"})
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
headers = dict(resp.headers)
|
||||
|
||||
important_headers = [
|
||||
"Strict-Transport-Security",
|
||||
"Content-Security-Policy",
|
||||
"X-Frame-Options",
|
||||
"X-Content-Type-Options",
|
||||
"Referrer-Policy",
|
||||
"Permissions-Policy"
|
||||
]
|
||||
|
||||
present = []
|
||||
missing = []
|
||||
header_keys_lower = {k.lower(): k for k in headers.keys()}
|
||||
|
||||
for h in important_headers:
|
||||
if h.lower() in header_keys_lower:
|
||||
present.append(h)
|
||||
else:
|
||||
missing.append(h)
|
||||
|
||||
score_ratio = len(present) / len(important_headers)
|
||||
if score_ratio >= 0.8: grade = "A"
|
||||
elif score_ratio >= 0.6: grade = "B"
|
||||
elif score_ratio >= 0.4: grade = "C"
|
||||
elif score_ratio >= 0.2: grade = "D"
|
||||
else: grade = "F"
|
||||
|
||||
return {
|
||||
"url": url,
|
||||
"grade": grade,
|
||||
"present": present,
|
||||
"missing": missing,
|
||||
"server": headers.get("Server", headers.get("server", "Hidden/Unknown")),
|
||||
"headers": headers
|
||||
}
|
||||
except Exception as e:
|
||||
return {"url": url, "error": str(e)}
|
||||
|
||||
def subdomains(domain, timeout=8.0):
|
||||
try:
|
||||
clean_dom = str(domain).replace("https://", "").replace("http://", "").split("/")[0]
|
||||
url = f"https://crt.sh/?q=%.{urllib.parse.quote(clean_dom)}&output=json"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
with urllib.request.urlopen(req, timeout=float(timeout)) as resp:
|
||||
data = json.loads(resp.read().decode('utf-8'))
|
||||
subs = set()
|
||||
for entry in data:
|
||||
name_val = entry.get("name_value", "")
|
||||
for sub in name_val.split("\n"):
|
||||
sub = sub.strip().lower()
|
||||
if sub and "*" not in sub:
|
||||
subs.add(sub)
|
||||
return sorted(list(subs))
|
||||
except Exception as e:
|
||||
return [f"Error fetching subdomains: {e}"]
|
||||
|
||||
def hash_identify(hash_str):
|
||||
h = str(hash_str).strip()
|
||||
l = len(h)
|
||||
is_hex = all(c in "0123456789abcdefABCDEF" for c in h)
|
||||
|
||||
if h.startswith("$2a$") or h.startswith("$2b$") or h.startswith("$2y$"):
|
||||
return "Bcrypt"
|
||||
if h.startswith("$6$"):
|
||||
return "SHA-512 Crypt"
|
||||
if h.startswith("$1$"):
|
||||
return "MD5 Crypt"
|
||||
|
||||
if is_hex:
|
||||
if l == 32: return "MD5 / NTLM"
|
||||
elif l == 40: return "SHA-1"
|
||||
elif l == 56: return "SHA-224"
|
||||
elif l == 64: return "SHA-256"
|
||||
elif l == 96: return "SHA-384"
|
||||
elif l == 128: return "SHA-512"
|
||||
|
||||
return "Unknown Hash Format"
|
||||
|
||||
def crack_md5(target_hash, wordlist):
|
||||
target = str(target_hash).lower().strip()
|
||||
words = []
|
||||
if isinstance(wordlist, list):
|
||||
words = wordlist
|
||||
elif isinstance(wordlist, str):
|
||||
if os.path.exists(wordlist):
|
||||
with open(wordlist, "r", encoding="utf-8", errors="ignore") as f:
|
||||
words = [line.strip() for line in f]
|
||||
else:
|
||||
words = [wordlist]
|
||||
|
||||
for w in words:
|
||||
if hashlib.md5(w.encode('utf-8')).hexdigest() == target:
|
||||
return w
|
||||
return None
|
||||
|
||||
def resolve(host):
|
||||
try:
|
||||
return socket.gethostbyname(str(host))
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
def reverse_dns(ip):
|
||||
try:
|
||||
return socket.gethostbyaddr(str(ip))[0]
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
|
||||
return AiraModule("sec", {
|
||||
"scan_port": scan_port,
|
||||
"scan_ports": scan_ports,
|
||||
"scan": scan_ports,
|
||||
"banner": banner,
|
||||
"audit_headers": audit_headers,
|
||||
"subdomains": subdomains,
|
||||
"hash_identify": hash_identify,
|
||||
"crack_md5": crack_md5,
|
||||
"resolve": resolve,
|
||||
"reverse_dns": reverse_dns
|
||||
})
|
||||
|
||||
def create_thread_module():
|
||||
def spawn(fn, args=None):
|
||||
if args is None:
|
||||
args = []
|
||||
elif not isinstance(args, (list, tuple)):
|
||||
args = [args]
|
||||
|
||||
def _runner():
|
||||
if callable(fn):
|
||||
fn(*args)
|
||||
|
||||
t = threading.Thread(target=_runner, daemon=True)
|
||||
t.start()
|
||||
return t
|
||||
|
||||
def join(t, timeout=None):
|
||||
if hasattr(t, "join"):
|
||||
t.join(timeout=float(timeout) if timeout is not None else None)
|
||||
return True
|
||||
return False
|
||||
|
||||
def sleep(seconds):
|
||||
time.sleep(float(seconds))
|
||||
return True
|
||||
|
||||
def pool(fn, items, max_workers=5):
|
||||
if not isinstance(items, (list, tuple)):
|
||||
items = list(items)
|
||||
|
||||
def _worker(item):
|
||||
if callable(fn):
|
||||
return fn(item)
|
||||
return None
|
||||
|
||||
with ThreadPoolExecutor(max_workers=int(max_workers)) as executor:
|
||||
return list(executor.map(_worker, items))
|
||||
|
||||
return AiraModule("thread", {
|
||||
"spawn": spawn,
|
||||
"start": spawn,
|
||||
"join": join,
|
||||
"sleep": sleep,
|
||||
"pool": pool
|
||||
})
|
||||
|
||||
BUILTIN_MODULES = {
|
||||
"file": create_file_module,
|
||||
"os": create_os_module,
|
||||
@@ -333,5 +646,9 @@ BUILTIN_MODULES = {
|
||||
"crypto": create_crypto_module,
|
||||
"string": create_string_module,
|
||||
"sqlite": create_sqlite_module,
|
||||
"net": create_net_module
|
||||
"net": create_net_module,
|
||||
"ai": create_ai_module,
|
||||
"sec": create_sec_module,
|
||||
"thread": create_thread_module
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user