노현종

insert AWS, Account class

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
namespace VulnCrawler
{
public static class AWS
{
[XmlRoot("MySqlAccountInfo")]
public class Account
{
public static string FilePath => @"D:\Account.xml";
[XmlAttribute("EndPoint")]
public string Endpoint { get; set; }
[XmlAttribute("ID")]
public string Id { get; set; }
[XmlAttribute("PW")]
public string Pw { get; set; }
}
private static Account account;
static AWS() {
// account = LoadAccount();
account = new Account() {
Endpoint = "aaa",
Id = "bbb",
Pw = "1231",
};
Console.WriteLine(account.Endpoint);
}
private static Account LoadAccount() {
if (!File.Exists(Account.FilePath)) {
return null;
}
Account acc = null;
// Deserialization
using (var reader = new StreamReader(Account.FilePath)) {
XmlSerializer xs = new XmlSerializer(typeof(Account));
acc = (Account)xs.Deserialize(reader);
}
return acc;
}
public static void SaveAccount() {
//File.SetAttributes(Account.FilePath, FileAttributes.Normal);
// Serialization
using (StreamWriter wr = new StreamWriter(Account.FilePath)) {
XmlSerializer xs = new XmlSerializer(typeof(Account));
xs.Serialize(wr, account);
}
}
}
}
......@@ -15,36 +15,35 @@ namespace VulnCrawler
{
static void Main(string[] args) {
string accountInfo = File.ReadAllText(@"c:\account.txt");
string id = accountInfo.Split(',')[0];
string pw = accountInfo.Split(',')[1];
MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder {
Server = "",
UserID = id,
Password = pw,
Database = "vuln",
Port = 3306
};
string strConn = builder.ToString();
builder = null;
MySqlConnection conn = new MySqlConnection(strConn);
AWS.SaveAccount();
//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 {
//try {
String sql = "INSERT INTO members (id, pwd, name) " +
"VALUES ('gon', '111', '김삿갓')";
// String sql = "INSERT INTO members (id, pwd, name) " +
// "VALUES ('gon', '111', '김삿갓')";
MySqlCommand cmd = new MySqlCommand(sql, conn);
// MySqlCommand cmd = new MySqlCommand(sql, conn);
conn.Open();
// conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
// cmd.ExecuteNonQuery();
// conn.Close();
//} catch (Exception e) {
// Console.WriteLine(e.ToString());
//}
// Run();
......
......@@ -53,6 +53,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AWS.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VulnPython.cs" />
......