Skip to content

Commit 1e69fc7

Browse files
author
Shafaf
committed
Temp: not completed
1 parent cc12f19 commit 1e69fc7

9 files changed

Lines changed: 186 additions & 131 deletions

File tree

.env.sample

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# APP_DB_DRIVER=postgresql
2+
# APP_DB_USER=postgres
3+
# APP_DB_PASS=postgres
4+
# APP_DB_HOST=localhost
5+
# APP_DB_PORT=5432
6+
# APP_DB_DATABASE=boilerplate_db
7+
8+
# Set the POSTGRES_USER and POSTGRES_PASSWORD
9+
export POSTGRES_USER=<user>
10+
export POSTGRES_PASSWORD=<password>
11+
export POSTGRES_HOST=<postgres>
12+
export POSTGRES_PORT=<5432>
13+
export POSTGRES_DB=<razorpay>
14+
15+
16+
# SQLALCHEMY_POOL_SIZE=10
17+
# SQLALCHEMY_POOL_TIMEOUT=300
18+
# SQLALCHEMY_POOL_RECYCLE=100
19+
# SQLALCHEMY_MAX_OVERFLOW=5
20+
21+
# FLASK_WEBSERVER_ADDRESS=0.0.0.0
22+
# FLASK_WEBSERVER_PORT=8088
23+
24+
# GUNICORN_WEBSERVER_TIMEOUT=30
25+
# GUNICORN_WORKERS=5
26+
27+
# FLASK_CONFIG_FILE_PATH=config.py
28+
29+
# MIGRATION_FOLDER_PATH=./src/migrations

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<div align="center">
2+
<h1><code>Razorpay Python Client </code></h1>
3+
<p><strong><em>Python bindings for interacting with the Razorpay API
4+
5+
This is primarily meant for merchants who wish to perform interactions with the Razorpay API programatically.</em></strong></p>
6+
</div>
7+
8+
---
9+
<!--
10+
## 📖 Table of Contents
11+
12+
- [Introduction](#%E2%84%B9%EF%B8%8F-introduction)
13+
- [Features](#features)
14+
- [Installation](#installation)
15+
- [Usage](#usage)
16+
- [Contribution](#contribution)
17+
- [License](#license)
18+
19+
## ℹ️ Introduction
20+
21+
**moonwalk** is a 400 KB single-binary executable that can clear your traces while penetration testing a **Unix** machine. It saves the state of system logs pre-exploitation and reverts that state including the filesystem timestamps post-exploitation leaving zero traces of a _ghost in the shell_.
22+
23+
⚠️ **NOTE:** This tool is open-sourced to assist solely in [**Red Team**](https://en.wikipedia.org/wiki/Red_team) operations and in no means is the author liable for repercussions caused by any prohibited use of this tool. Only make use of this in a machine you have permission to test.
24+
25+
## Features
26+
27+
- **Small Executable:** Get started quickly with a `curl` fetch to your target machine.
28+
- **Fast:** Performs all session commands including logging, trace clearing, and filesystem operations in under 5 milliseconds.
29+
- **Reconnaissance:** To save the state of system logs, `moonwalk` finds a world-writable path and saves the session under a dot directory which is removed upon ending the session.
30+
- **Shell History:** Instead of clearing the whole history file, `moonwalk` reverts it back to how it was including the invokation of `moonwalk`.
31+
- **Filesystem Timestamps:** Hide from the Blue Team by reverting the access/modify timestamps of files back to how it was using the [`GET`](#usage) command.
32+
33+
## Installation
34+
35+
```
36+
$ curl -L https://github.com/mufeedvh/moonwalk/releases/download/v1.0.0/moonwalk_linux -o moonwalk
37+
```
38+
39+
(`AMD x86-64`)
40+
41+
**OR**
42+
43+
Download the executable from [**Releases**](https://github.com/mufeedvh/moonwalk/releases) OR Install with `cargo`:
44+
45+
$ cargo install --git https://github.com/mufeedvh/moonwalk.git
46+
47+
[Install Rust/Cargo](https://rust-lang.org/tools/install)
48+
49+
## Build From Source
50+
51+
**Prerequisites:**
52+
53+
* [Git](https://git-scm.org/downloads)
54+
* [Rust](https://rust-lang.org/tools/install)
55+
* Cargo (Automatically installed when installing Rust)
56+
* A C linker (Only for Linux, generally comes pre-installed)
57+
58+
```
59+
$ git clone https://github.com/mufeedvh/moonwalk.git
60+
$ cd moonwalk/
61+
$ cargo build --release
62+
```
63+
64+
The first command clones this repository into your local machine and the last two commands enters the directory and builds the source in release mode.
65+
66+
## Usage
67+
68+
<div align="center">
69+
<table>
70+
<tr>
71+
<td><img height="300" width="400" src="https://user-images.githubusercontent.com/26198477/146672354-9db1e7e5-bb8a-43e5-8b64-b2d1bbea547e.png"></td>
72+
</tr>
73+
</table>
74+
</div>
75+
76+
Once you get a shell into the target Unix machine, start a moonwalk session by running this command:
77+
78+
$ moonwalk start
79+
80+
While you're doing recon/exploitation and messing with any files, get the `touch` timestamp command of a file beforehand to revert it back after you've accessed/modified it:
81+
82+
$ moonwalk get ~/.bash_history
83+
84+
Post-exploitation, clear your traces and close the session with this command:
85+
86+
$ moonwalk finish
87+
88+
That's it!
89+
90+
## Contribution
91+
92+
Ways to contribute:
93+
94+
- Suggest a feature
95+
- Report a bug
96+
- Fix something and open a pull request
97+
- Help me document the code
98+
- Spread the word
99+
- Find something I missed which leaves any trace!
100+
101+
## License
102+
103+
Licensed under the MIT License, see <a href="https://github.com/mufeedvh/moonwalk/blob/master/LICENSE">LICENSE</a> for more information. -->

app.py

Lines changed: 29 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,29 @@
1-
from flask import Flask, request, render_template, url_for, flash, redirect
2-
from flask_sqlalchemy import SQLAlchemy
3-
from flask_migrate import Migrate
4-
from werkzeug.security import generate_password_hash, check_password_hash
5-
from sqlalchemy_utils import UUIDType
6-
import os
7-
import uuid
8-
9-
# SQLAlchemy.
10-
pg_user = os.getenv("POSTGRES_USER", "postgres")
11-
pg_pass = os.getenv("POSTGRES_PASSWORD", "postgres")
12-
pg_host = os.getenv("POSTGRES_HOST", "postgres")
13-
pg_port = os.getenv("POSTGRES_PORT", "5432")
14-
pg_db = os.getenv("POSTGRES_DB", pg_user)
15-
16-
app = Flask(__name__, template_folder="./templates")
17-
18-
# db configuration
19-
app.config["SQLALCHEMY_DATABASE_URI"] = (
20-
f"postgresql://{pg_user}:{pg_pass}@localhost:{pg_port}/{pg_db}"
21-
)
22-
23-
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
24-
app.config["SECRET_KEY"] = "your-secret-key"
25-
26-
db = SQLAlchemy(app)
27-
migrate = Migrate(app, db)
28-
29-
# Base model class for all models
30-
class BaseModel(db.Model):
31-
"""
32-
Base model of the mapping class inheritace
33-
34-
https://docs.sqlalchemy.org/en/14/orm/inheritance.html
35-
"""
36-
37-
__abstract__ = True
38-
39-
STATUS_CHOICES = ["Active", "Disabled", "Deleted"]
40-
41-
id = db.Column(UUIDType(binary=False), primary_key=True, default=uuid.uuid4)
42-
name = db.Column(db.String(255), nullable=False)
43-
extra = db.Column(db.JSON(), nullable=True)
44-
status = db.Column(
45-
db.Enum(*STATUS_CHOICES, name="status", native_enum=False),
46-
nullable=False,
47-
default="active"
48-
)
49-
50-
# User Model
51-
class User(BaseModel):
52-
id = db.Column(db.Integer, primary_key=True)
53-
username = db.Column(db.String(80), unique=True, nullable=False)
54-
password = db.Column(db.String(520), nullable=False)
55-
56-
57-
class Student(BaseModel):
58-
id = db.Column(db.Integer, primary_key=True)
59-
student_name = db.Column(db.String(200), nullable=False)
60-
student_age = db.Column(db.Integer, nullable=True)
61-
student_course = db.Column(db.String(200), nullable=True)
62-
63-
64-
# Routes
65-
@app.route("/")
66-
def index():
67-
return "Welcome you again"
68-
69-
70-
@app.route("/login", methods=["GET", "POST"])
71-
def login():
72-
if request.method == "POST":
73-
username = request.form["username"]
74-
password = request.form["password"]
75-
76-
user = User.query.filter_by(username=username).first()
77-
78-
if user and check_password_hash(user.password, password):
79-
flash("Login successful", "success")
80-
# You can redirect to a dashboard or profile page here
81-
return redirect(url_for("index"))
82-
else:
83-
flash("Invalid username or password", "danger")
84-
return render_template("login.html")
85-
86-
87-
@app.route("/register", methods=["GET", "POST"])
88-
def register():
89-
if request.method == "POST":
90-
username = request.form["username"]
91-
password = request.form["password"]
92-
93-
# check if the user is already registered
94-
existing_user = User.query.filter_by(username=username).first()
95-
print(existing_user)
96-
97-
if existing_user:
98-
flash("User name already exist, Please choose another", "danger")
99-
else:
100-
# create a new user
101-
new_user = User(
102-
username=username,
103-
password=password,
104-
name=username,
105-
)
106-
db.session.add(new_user)
107-
db.session.commit()
108-
flash("Registration successful. You can now log in.", "success")
109-
return redirect(url_for("login"))
110-
111-
else:
112-
return render_template("register.html")
113-
114-
115-
if __name__ == "__main__":
116-
app.run(debug=True)
1+
from flask import Flask
2+
from sqlalchemy import create_engine
3+
4+
from connection import conn
5+
from model.subscription import hello
6+
7+
def create_app():
8+
app = Flask(__name__)
9+
10+
# open a cursor to perform database operations
11+
cur = conn.cursor()
12+
# print("Cursor opened successfully", cur)
13+
# engine = create_engine('postgresql:///tutorial.db', echo=True)
14+
hello()
15+
# Execute a database query
16+
cur.execute("SELECT * FROM student;")
17+
18+
# Fetch the result
19+
result = cur.fetchall()
20+
print("Result fetched successfully")
21+
22+
@app.route("/")
23+
def index():
24+
return result
25+
26+
return app
27+
28+
29+
create_app()

connection.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
import psycopg2;
3+
4+
# Get the environment variables
5+
DB_USER = os.getenv('POSTGRES_USER', "postgres")
6+
DB_PASSWORD = os.getenv('POSTGRES_PASSWORD', "postgres")
7+
# DB_HOST = os.getenv('POSTGRES_HOST', "postgres")
8+
DB_PORT = os.getenv('POSTGRES_PORT', "5432")
9+
DB_NAME = os.getenv('POSTsGRES_DB', "demodb")
10+
11+
# database connection login
12+
conn = psycopg2.connect(
13+
dbname=DB_NAME,
14+
user=DB_USER,
15+
password=DB_PASSWORD,
16+
port=DB_PORT
17+
)
18+

model/__init__.py

Whitespace-only changes.

model/subscription.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
3+
# engine = create_engine('postgresql:///tutorial.db', echo=True)
4+
def hello():
5+
print("Hello from database.py")
6+
print("========== Database connection established successfully ==========")

requirements.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
alembic==1.13.1
2-
blinker==1.7.0
3-
click==8.1.7
41
Flask==3.0.2
5-
Flask-Migrate==4.0.5
6-
Flask-SQLAlchemy==3.1.1
7-
importlib-metadata==7.0.1
8-
itsdangerous==2.1.2
9-
Jinja2==3.1.3
10-
Mako==1.3.2
11-
MarkupSafe==2.1.5
122
psycopg2==2.9.9
13-
SQLAlchemy==2.0.25
14-
SQLAlchemy-Utils==0.41.1
15-
typing_extensions==4.9.0
16-
Werkzeug==3.0.1
17-
zipp==3.17.0
3+
SQLAlchemy==2.0.29

utils/__init__.py

Whitespace-only changes.

utils/database.py

Whitespace-only changes.

0 commit comments

Comments
 (0)