Program.cs
4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using LibGit2Sharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
//using MySql.Data.MySqlClient;
using AESENC;
using System.Security;
using System.Runtime.InteropServices;
namespace VulnCrawler
{
class Program
{
static void Main(string[] args) {
//SecureString s_key = GetConsoleSecurePassword();
//Console.Clear();
//string key = SecureStringToString(s_key);
////AWS.SaveAccount();
//AES aes = new AES();
//string txt = File.ReadAllText(@"Account.xml");
//string xml = aes.AESDecrypt128(txt, key);
//AWS.LoadAccount(xml);
//AWS.Account account = AWS.account;
//Console.WriteLine($"Endpoint: {account.Endpoint}, ID: {account.Id}, PW: {account.Pw}");
//MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder {
// Server = "",
// UserID = id,
// Password = pw,
// Database = "vuln",
// Port = 3306
//};
//string strConn = builder.ToString();
//builder = null;
//MySqlConnection conn = new MySqlConnection(strConn);
//try {
// String sql = "INSERT INTO members (id, pwd, name) " +
// "VALUES ('gon', '111', '김삿갓')";
// MySqlCommand cmd = new MySqlCommand(sql, conn);
// conn.Open();
// cmd.ExecuteNonQuery();
// conn.Close();
//} catch (Exception e) {
// Console.WriteLine(e.ToString());
//}
Run();
}
public static void Run() {
// Repository 폴더들이 있는 주소를 지정하면 하위 폴더 목록을 가져옴(Repository 목록)
var directorys = Directory.GetDirectories(@"c:\VulnPy");
if (directorys.Length == 0) {
Console.WriteLine("Repository 목록 찾기 실패");
return;
}
// Repository 목록 만큼 반복함.
foreach (var directory in directorys) {
VulnWorker.Run<VulnPython>(directory);
}
}
static String SecureStringToString(SecureString value) {
IntPtr valuePtr = IntPtr.Zero;
try {
valuePtr = Marshal.SecureStringToGlobalAllocUnicode(value);
return Marshal.PtrToStringUni(valuePtr);
} finally {
Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
}
}
private static SecureString GetConsoleSecurePassword() {
SecureString pwd = new SecureString();
while (true) {
ConsoleKeyInfo i = Console.ReadKey(true);
if (i.Key == ConsoleKey.Enter) {
break;
} else if (i.Key == ConsoleKey.Backspace) {
pwd.RemoveAt(pwd.Length - 1);
Console.Write("\b \b");
} else {
pwd.AppendChar(i.KeyChar);
Console.Write("*");
}
}
return pwd;
}
/// <summary>
/// 디렉토리 삭제 함수
/// </summary>
/// <param name="targetDir"></param>
public static void DeleteDirectory(string targetDir) {
File.SetAttributes(targetDir, FileAttributes.Normal);
string[] files = Directory.GetFiles(targetDir);
string[] dirs = Directory.GetDirectories(targetDir);
foreach (string file in files) {
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs) {
DeleteDirectory(dir);
}
Directory.Delete(targetDir, false);
}
}
}