Merge branch 'master' of https://github.com/yhackerbv/VulnNottiProject
Showing
1 changed file
with
46 additions
and
16 deletions
... | @@ -104,9 +104,9 @@ namespace VulnCrawler | ... | @@ -104,9 +104,9 @@ namespace VulnCrawler |
104 | public static void _InsertVulnData(_Vuln vuln) | 104 | public static void _InsertVulnData(_Vuln vuln) |
105 | { | 105 | { |
106 | String sql = string.Empty; | 106 | String sql = string.Empty; |
107 | - // vulnId setting (마지막 vulnId +1) | ||
108 | MySqlCommand cmd = null; | 107 | MySqlCommand cmd = null; |
109 | 108 | ||
109 | + // vulnId setting (마지막 vulnId +1) | ||
110 | int last_vulnId = 1; | 110 | int last_vulnId = 1; |
111 | try | 111 | try |
112 | { | 112 | { |
... | @@ -129,12 +129,12 @@ namespace VulnCrawler | ... | @@ -129,12 +129,12 @@ namespace VulnCrawler |
129 | //db에 추가 | 129 | //db에 추가 |
130 | cmd.CommandText = "INSERT INTO vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) VALUES(@vulnId, @cve, @funcName, @lenFunc, @code, @blockHash, @url)"; | 130 | cmd.CommandText = "INSERT INTO vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) VALUES(@vulnId, @cve, @funcName, @lenFunc, @code, @blockHash, @url)"; |
131 | cmd.Parameters.AddWithValue("@vulnId", last_vulnId); | 131 | cmd.Parameters.AddWithValue("@vulnId", last_vulnId); |
132 | - cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'"); | 132 | + cmd.Parameters.AddWithValue("@cve", $"{vuln.Cve}"); |
133 | - cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'"); | 133 | + cmd.Parameters.AddWithValue("@funcName", $"{vuln.FuncName}"); |
134 | cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}"); | 134 | cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}"); |
135 | - cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'"); | 135 | + cmd.Parameters.AddWithValue("@code", $"{vuln.Code}"); |
136 | - cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'"); | 136 | + cmd.Parameters.AddWithValue("@blockHash", $"{vuln.BlockHash}"); |
137 | - cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'"); | 137 | + cmd.Parameters.AddWithValue("@url", $"{vuln.Url}"); |
138 | cmd.ExecuteNonQuery(); | 138 | cmd.ExecuteNonQuery(); |
139 | //콘솔출력용 | 139 | //콘솔출력용 |
140 | sql = "INSERT INTO vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) " + | 140 | sql = "INSERT INTO vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) " + |
... | @@ -182,7 +182,7 @@ namespace VulnCrawler | ... | @@ -182,7 +182,7 @@ namespace VulnCrawler |
182 | //db에 추가 | 182 | //db에 추가 |
183 | cmd.CommandText = "INSERT INTO userInfo(userId, repositName, vulnId) VALUES(@userId, @repositName, @vulnId)"; | 183 | cmd.CommandText = "INSERT INTO userInfo(userId, repositName, vulnId) VALUES(@userId, @repositName, @vulnId)"; |
184 | cmd.Parameters.AddWithValue("@userId", last_userId); | 184 | cmd.Parameters.AddWithValue("@userId", last_userId); |
185 | - cmd.Parameters.AddWithValue("@repositName", $"'{user.RepositName}'"); | 185 | + cmd.Parameters.AddWithValue("@repositName", $"{user.RepositName}"); |
186 | cmd.Parameters.AddWithValue("@vulnInfo", $"{user.VulnId}"); | 186 | cmd.Parameters.AddWithValue("@vulnInfo", $"{user.VulnId}"); |
187 | cmd.ExecuteNonQuery(); | 187 | cmd.ExecuteNonQuery(); |
188 | //콘솔출력용 | 188 | //콘솔출력용 |
... | @@ -215,12 +215,12 @@ namespace VulnCrawler | ... | @@ -215,12 +215,12 @@ namespace VulnCrawler |
215 | //해당 vuln Update | 215 | //해당 vuln Update |
216 | cmd.CommandText = "UPDATE vuln_Info SET cve=@cve,funcName=@funcName,lenFunc=@lenFunc,code=@code,blockHash=@blockHash,url=@url WHERE vulnId=@vulnId"; | 216 | cmd.CommandText = "UPDATE vuln_Info SET cve=@cve,funcName=@funcName,lenFunc=@lenFunc,code=@code,blockHash=@blockHash,url=@url WHERE vulnId=@vulnId"; |
217 | cmd.Parameters.AddWithValue("@vulnId", _vulnId); | 217 | cmd.Parameters.AddWithValue("@vulnId", _vulnId); |
218 | - cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'"); | 218 | + cmd.Parameters.AddWithValue("@cve", $"{vuln.Cve}"); |
219 | - cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'"); | 219 | + cmd.Parameters.AddWithValue("@funcName", $"{vuln.FuncName}"); |
220 | cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}"); | 220 | cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}"); |
221 | - cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'"); | 221 | + cmd.Parameters.AddWithValue("@code", $"{vuln.Code}"); |
222 | - cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'"); | 222 | + cmd.Parameters.AddWithValue("@blockHash", $"{vuln.BlockHash}"); |
223 | - cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'"); | 223 | + cmd.Parameters.AddWithValue("@url", $"{vuln.Url}"); |
224 | cmd.ExecuteNonQuery(); | 224 | cmd.ExecuteNonQuery(); |
225 | //콘솔출력용 | 225 | //콘솔출력용 |
226 | sql = "UPDATE vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) " + | 226 | sql = "UPDATE vuln_Info(vulnId, cve, funcName, lenFunc, code, blockHash, url) " + |
... | @@ -255,10 +255,10 @@ namespace VulnCrawler | ... | @@ -255,10 +255,10 @@ namespace VulnCrawler |
255 | //해당 user Update | 255 | //해당 user Update |
256 | cmd.CommandText = "UPDATE userInfo SET repositName=@repositName, vulnId=@vulnId WHERE userId=@userId"; | 256 | cmd.CommandText = "UPDATE userInfo SET repositName=@repositName, vulnId=@vulnId WHERE userId=@userId"; |
257 | cmd.Parameters.AddWithValue("@userId", _userId); | 257 | cmd.Parameters.AddWithValue("@userId", _userId); |
258 | - cmd.Parameters.AddWithValue("@repositName", $"'{user.RepositName}'"); | 258 | + cmd.Parameters.AddWithValue("@repositName", $"{user.RepositName}"); |
259 | - cmd.Parameters.AddWithValue("@vulnId", $"'{user.VulnId}'"); | 259 | + cmd.Parameters.AddWithValue("@vulnId", $"{user.VulnId}"); |
260 | - | ||
261 | cmd.ExecuteNonQuery(); | 260 | cmd.ExecuteNonQuery(); |
261 | + | ||
262 | //콘솔출력용 | 262 | //콘솔출력용 |
263 | sql = "UPDATE userInfo(userId, repositName, vulnId) " + | 263 | sql = "UPDATE userInfo(userId, repositName, vulnId) " + |
264 | $"VALUES({_userId}, '{user.RepositName}', '{user.VulnId}')"; | 264 | $"VALUES({_userId}, '{user.RepositName}', '{user.VulnId}')"; |
... | @@ -279,13 +279,14 @@ namespace VulnCrawler | ... | @@ -279,13 +279,14 @@ namespace VulnCrawler |
279 | } | 279 | } |
280 | public static _Vuln SelectVulnData(int _vulnId) { | 280 | public static _Vuln SelectVulnData(int _vulnId) { |
281 | _Vuln vuln = new _Vuln(); | 281 | _Vuln vuln = new _Vuln(); |
282 | + | ||
282 | String sql = string.Empty; | 283 | String sql = string.Empty; |
283 | MySqlCommand cmd = new MySqlCommand(); | 284 | MySqlCommand cmd = new MySqlCommand(); |
284 | cmd.Connection = Conn; | 285 | cmd.Connection = Conn; |
285 | cmd.CommandText = "SELECT * FROM vuln_Info"; | 286 | cmd.CommandText = "SELECT * FROM vuln_Info"; |
286 | 287 | ||
287 | System.Data.DataSet ds = new System.Data.DataSet(); | 288 | System.Data.DataSet ds = new System.Data.DataSet(); |
288 | - MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM userInfo", Conn); | 289 | + MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM vuln_Info", Conn); |
289 | da.Fill(ds); | 290 | da.Fill(ds); |
290 | 291 | ||
291 | //vuln에 입력 | 292 | //vuln에 입력 |
... | @@ -385,5 +386,34 @@ namespace VulnCrawler | ... | @@ -385,5 +386,34 @@ namespace VulnCrawler |
385 | Console.ReadLine(); | 386 | Console.ReadLine(); |
386 | } | 387 | } |
387 | } | 388 | } |
389 | + public static List<_Vuln> SelectVulnbyLen(int _lenFunc) | ||
390 | + { | ||
391 | + var list = new List<_Vuln>(); | ||
392 | + String sql = string.Empty; | ||
393 | + MySqlCommand cmd = new MySqlCommand(); | ||
394 | + cmd.Connection = Conn; | ||
395 | + cmd.CommandText = "SELECT * FROM vuln_Info where lenFunc=" + _lenFunc; | ||
396 | + | ||
397 | + System.Data.DataSet ds = new System.Data.DataSet(); | ||
398 | + MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM vuln_Info where lenFunc=" + _lenFunc, Conn); | ||
399 | + da.Fill(ds); | ||
400 | + | ||
401 | + //vuln에 입력 | ||
402 | + foreach (System.Data.DataRow row in ds.Tables[0].Rows) | ||
403 | + { | ||
404 | + _Vuln vuln = new _Vuln(); | ||
405 | + vuln.VulnId = Convert.ToInt32(row["vulnId"]); | ||
406 | + vuln.Cve = Convert.ToString(row["cve"]); | ||
407 | + vuln.FuncName = Convert.ToString(row["funcName"]); | ||
408 | + vuln.LenFunc = Convert.ToInt32(row["lenFunc"]); | ||
409 | + vuln.Code = Convert.ToString(row["code"]); | ||
410 | + vuln.BlockHash = Convert.ToString(row["blockHash"]); | ||
411 | + vuln.Url = Convert.ToString(row["url"]); | ||
412 | + list.Add(vuln); | ||
413 | + } | ||
414 | + //해당 list 반환 | ||
415 | + return list; | ||
416 | + } | ||
417 | + | ||
388 | } | 418 | } |
389 | } | 419 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment