Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed admin bug + more #5

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Engine/SqlLiteHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public bool Delete(String tableName, String where)
}
catch (Exception fail)
{
//MessageBox.Show(fail.Message);
Console.WriteLine(fail.Message);
returnCode = false;
}
return returnCode;
Expand Down Expand Up @@ -176,7 +176,7 @@ public bool Insert(String tableName, Dictionary<String, String> data)
}
catch (Exception fail)
{
// MessageBox.Show(fail.Message);
Console.WriteLine(fail.Message);
returnCode = false;
}
return returnCode;
Expand Down
143 changes: 78 additions & 65 deletions Plugins/GPGAuth/GPGAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void Bot_OnMessage(Network n, Irc.IrcEventArgs e)
catch (Exception ex)
{
Answer(n, e, "An error occurred, please try again.");
Console.WriteLine(ex.Message);
}

bool isadmin = Bot.isAdmin(e.Data.Nick);
Expand All @@ -78,44 +79,41 @@ void Bot_OnMessage(Network n, Irc.IrcEventArgs e)
}

//Process Normal Commands
if (!isadmin)
switch (mes)
{
switch (mes)
{
case "register":
register(n, e);
break;
case "eauth":
login(n, e, false);
break;
case "leauth":
login(n, e, true);
break;
case "everify":
loginconf(n, e);
break;
case "ident":
ident(n, e);
break;
case "bizident":
bizident(n, e);
break;
case "logout":
logout(n, e);
break;
case "email":
emailogin(n, e);
break;
case "setemail":
setemail(n, e);
break;
case "login":
help(n, e);
break;
default:
//Answer(n, e, "I do not know that command, " + e.Data.Nick);
break;
}
case "register":
register(n, e);
break;
case "eauth":
login(n, e, false);
break;
case "leauth":
login(n, e, true);
break;
case "everify":
loginconf(n, e);
break;
case "ident":
ident(n, e);
break;
case "bizident":
bizident(n, e);
break;
case "logout":
logout(n, e);
break;
case "email":
emailogin(n, e);
break;
case "setemail":
setemail(n, e);
break;
case "login":
help(n, e);
break;
default:
//Answer(n, e, "I do not know that command, " + e.Data.Nick);
break;
}
}
}
Expand Down Expand Up @@ -213,18 +211,26 @@ protected void emailogin(Network n, Irc.IrcEventArgs e)
id++;
if (account["NAME"] as string == name && account["EMAIL"].ToString().Length > 0)
{
Answer(n, e, FormatItalic(e.Data.Nick + ": .. sending #email, please be patient.."));
gpg.Recipient = account["key"] as string;
MemoryStream unencrypted = new MemoryStream(Encoding.ASCII.GetBytes(name + ":" + DateTime.Now.Ticks + "\n"));
MemoryStream encrypted = new MemoryStream();
gpg.Encrypt(unencrypted, encrypted);
Dictionary<String, String> data = new Dictionary<String, String>();
data.Add("verify", StreamToString(unencrypted));
db.Update("accounts", data, String.Format("id = {0}", id));
GmailSender g = new GmailSender("MrTiggr@BitcoinPolice.org", "LAcIYB<4;=~zAbW{}7Tdjk,kW!Nq.~-C");
g.Send("MrTiggr@BitcoinPolice.org", account["EMAIL"].ToString(), "#bitcoin-police gpg login request for: " + name, StreamToString(encrypted));
Answer(n, e, e.Data.Nick + ": An Email has been sent to your registered email address. Decrypt the contents using your GpG Key and then send IRC message " + FormatBold("#everify <decodedctext>") + " to login.");
noemail = false;
try
{
Answer(n, e, FormatItalic(e.Data.Nick + ": .. sending #email, please be patient.."));
gpg.Recipient = account["key"] as string;
MemoryStream unencrypted = new MemoryStream(Encoding.ASCII.GetBytes(name + ":" + DateTime.Now.Ticks + "\n"));
MemoryStream encrypted = new MemoryStream();
gpg.Encrypt(unencrypted, encrypted);
Dictionary<String, String> data = new Dictionary<String, String>();
data.Add("verify", StreamToString(unencrypted));
db.Update("accounts", data, String.Format("id = {0}", id));
GmailSender g = new GmailSender("MrTiggr@BitcoinPolice.org", "LAcIYB<4;=~zAbW{}7Tdjk,kW!Nq.~-C");
g.Send("MrTiggr@BitcoinPolice.org", account["EMAIL"].ToString(), "#bitcoin-police gpg login request for: " + name, StreamToString(encrypted));
Answer(n, e, e.Data.Nick + ": An Email has been sent to your registered email address. Decrypt the contents using your GpG Key and then send IRC message " + FormatBold("#everify <decodedctext>") + " to login.");
noemail = false;
}
catch (Exception ex)
{
Answer(n, e, "Failed to send email, something went wrong.");
Console.WriteLine(ex.Message);
}
}
}
if (noemail)
Expand Down Expand Up @@ -307,28 +313,35 @@ protected void login(Network n, Irc.IrcEventArgs e, bool wget)
id++;
if (account["NAME"] as string == name)
{
gpg.Recipient = account["key"] as string;
MemoryStream unencrypted = new MemoryStream(Encoding.ASCII.GetBytes(name + ":" + DateTime.Now.Ticks + "\n"));
MemoryStream encrypted = new MemoryStream();
gpg.Encrypt(unencrypted, encrypted);
try
{
gpg.Recipient = account["key"] as string;
MemoryStream unencrypted = new MemoryStream(Encoding.ASCII.GetBytes(name + ":" + DateTime.Now.Ticks + "\n"));
MemoryStream encrypted = new MemoryStream();
gpg.Encrypt(unencrypted, encrypted);


Dictionary<String, String> data = new Dictionary<String, String>();
data.Add("verify", StreamToString(unencrypted));
db.Update("accounts", data, String.Format("id = {0}", id));
Dictionary<String, String> data = new Dictionary<String, String>();
data.Add("verify", StreamToString(unencrypted));
db.Update("accounts", data, String.Format("id = {0}", id));

Pastie p = new Pastie();
string pastie = p.SendViaPasteBin(StreamToString(encrypted), "#bitcoin-police gpg login request for: " + name);
string[] paste = pastie.Split('/');
if (wget)
{
Answer(n, e, e.Data.Nick + ": wget -qO " + FormatBold("http://pastebin.com/raw.php?i=" + paste[3]) + " | gpg --decrypt");
Pastie p = new Pastie();
string pastie = p.SendViaPasteBin(StreamToString(encrypted), "#bitcoin-police gpg login request for: " + name);
string[] paste = pastie.Split('/');
if (wget)
{
Answer(n, e, e.Data.Nick + ": wget -qO " + FormatBold("http://pastebin.com/raw.php?i=" + paste[3]) + " | gpg --decrypt");
}
else
{
Answer(n, e, e.Data.Nick + ": Request here: " + FormatBold("http://pastebin.com/raw.php?i=" + paste[3]));
}
}
else
catch (Exception ex)
{
Answer(n, e, e.Data.Nick + ": Request here: "+ FormatBold("http://pastebin.com/raw.php?i=" + paste[3]));
Answer(n, e, "An error occured, please try again.");
Console.WriteLine(ex.Message);
}

}
}
}
Expand Down