Skip to content

Commit 7121cc5

Browse files
committed
minor code change
1 parent 17f53b6 commit 7121cc5

File tree

18 files changed

+58
-84
lines changed

18 files changed

+58
-84
lines changed

miscellaneous/csv_update/csv_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pandas as pd
99

1010

11-
class UserInput:
11+
class MyUtils:
1212
def __init__(self):
1313
self.parser = argparse.ArgumentParser(
1414
description="csv update")
@@ -45,7 +45,7 @@ def auto_triage(master_csv, month_csv, output_csv):
4545

4646

4747
if __name__ == "__main__":
48-
my_input = UserInput()
48+
my_input = MyUtils()
4949
args = my_input.parser.parse_args()
5050

5151
if len(sys.argv) == 1:

utils/octo_prepare/README.md renamed to utils/create_blog/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
## Description
22

3-
`octo_prepare.py` is used to generate posts for `Greyshell's Diary`.
3+
`create_blog.py` is used to generate posts for my `Greyshell's Diary`.
44

55
### How to use
66

77
1. write down notes in `markdown` format.
88
2. when you paste a image, it gets stored inside the filename.assets folder.
99
3. If that note needs to be published then set `comments: true` and set a categories like `categories: windows-exploit-dev`.
10-
- Available categories: windows-exploit-dev, linux-exploit-dev, web-security, network-security, capture-the-flag
10+
- Available categories: `windows-exploit-dev`, `linux-exploit-dev`, `web-security`, `network-security`, `capture-the-flag`
1111
4. use markdown preview for `view only` mode.
1212
5. how to include / show the content of a .txt file: create a `.py` file and copy the content inside the multiline comment section.
1313
6. how to use python code: copy the python file into the `octopress/source/artifacts/<filename>.assets` folder directly.
@@ -25,7 +25,7 @@
2525

2626
### Usage
2727
```
28-
usage: octo_prepare.py [-h] -c
28+
usage: create_blog.py [-h] -c
2929
3030
create blog posts for octopress
3131

utils/create_blog/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"src_dir": "/Users/abhijitsinha/Dropbox/grey_diary/",
3+
"dst_dir": "/Users/abhijitsinha/Dropbox/octopress/source/_posts/",
4+
"publish_flag": "true",
5+
"blacklisted_dirs": [".git", ""],
6+
"whitelisted_filetypes": [".md", ".markdown"],
7+
"skipped_files": [".py", ".txt", ".java", ".c",".cpp", ".js"],
8+
"platform": "mac"
9+
}

utils/octo_prepare/octo_prepare.py renamed to utils/create_blog/create_blog.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import sys
1212

1313

14-
class UserInput:
14+
class MyUtils:
1515
def __init__(self):
1616
self.parser = argparse.ArgumentParser(
17-
description="create blog posts for octopress")
17+
description="create blog posts for octopress")
1818
self.parser.add_argument(
19-
"-c", "--config", metavar="", help="provide a .json file", required=True)
19+
"-c", "--config", metavar="", help="provide a .json file", required=True)
2020

2121

2222
class Octopress:
@@ -143,11 +143,10 @@ def process_markdown(self):
143143
continue
144144

145145
if date != "" and comments == "true":
146-
print(f"[x] {file} => comment : true")
147146
# remove unused images
148147
asset_dir = root + "/" + name + ".assets/"
149148
self._remove_unused_image(
150-
asset_dir, absolute_file_path, self._skipped_files)
149+
asset_dir, absolute_file_path, self._skipped_files)
151150

152151
# prepare the file name
153152
new_file_name = date + "-" + name.replace('_', '-') + ".markdown"
@@ -196,7 +195,7 @@ def process_markdown(self):
196195

197196

198197
if __name__ == "__main__":
199-
my_input = UserInput()
198+
my_input = MyUtils()
200199
args = my_input.parser.parse_args()
201200

202201
if len(sys.argv) == 1:

utils/creds_manager/creds_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import keyring
1111

1212

13-
class UserInput:
13+
class MyUtils:
1414
def __init__(self):
1515
self.parser = argparse.ArgumentParser(
1616
description="a helper script / wrapper to perform all keyring operations")
@@ -64,7 +64,7 @@ def del_keyring(keyring_name):
6464

6565

6666
if __name__ == "__main__":
67-
my_input = UserInput()
67+
my_input = MyUtils()
6868
args = my_input.parser.parse_args()
6969

7070
if len(sys.argv) == 1:

utils/lab_vpn/lab_vpn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"""
2424

2525

26-
class UserInput:
26+
class MyUtils:
2727
def __init__(self):
2828
self.parser = argparse.ArgumentParser(
2929
description="automate the openvpn lab connection")
@@ -156,7 +156,7 @@ def lab_connection(self):
156156

157157

158158
if __name__ == "__main__":
159-
my_input = UserInput()
159+
my_input = MyUtils()
160160
args = my_input.parser.parse_args()
161161

162162
if len(sys.argv) == 1:

utils/octo_prepare/config.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

web/dblib/mysql_db.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# description: setup mysql db connection
55

66
import mysql.connector
7-
import keyring
7+
import os
88

99

1010
class MySQLdb:
@@ -16,10 +16,19 @@ def __init__(self):
1616
"""
1717
create a database connection for MySQL database
1818
"""
19+
try:
20+
import keyring
21+
username = keyring.get_password('mysql', 'username')
22+
password = keyring.get_password('mysql', 'password')
23+
except ImportError as err:
24+
print(f"inside the container: {err}")
25+
username = os.environ.get("username")
26+
password = os.environ.get("password")
27+
1928
try:
2029
# pick database credentials from keyring
21-
self.conn = mysql.connector.connect(user=keyring.get_password('mysql', 'username'),
22-
password=keyring.get_password('mysql', 'password'),
30+
self.conn = mysql.connector.connect(user=username,
31+
password=password,
2332
host='localhost',
2433
database='vulnapp')
2534

web/sqli/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import string
88
from flask import Flask, render_template
99
from flask import request
10-
from web.sqli.models import *
10+
from models import *
1111
from mysql_db import MySQLdb
1212

1313
templates_path = os.path.abspath(
@@ -18,7 +18,8 @@
1818

1919
@app.before_request
2020
def before_request_func():
21-
MySQLdb() # create database
21+
# create the database
22+
MySQLdb(host="localhost", db_name="vulnapp")
2223

2324

2425
@app.after_request
@@ -86,4 +87,4 @@ def tbl_post03():
8687

8788

8889
if __name__ == '__main__':
89-
app.run(port=9000, debug=True)
90+
app.run(host='0.0.0.0', port=9000, debug=True)

web/sqli/db_house-keeping/db_clean-up.sql

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)