using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;
namespace Malicious
{
public partial class Form1 : Form
{
private readonly string BBSURL = "http://bbs.XXXXX.com";
private readonly string USERNAME = "Malicious";
private readonly string PASSWORD = "123456";
private CookieCollection gCookieCollention = null;
private HttpWebRequest BBSRequest = null;
private HttpWebResponse BBSResponse = null;
public Form1()
{
InitializeComponent();
}
private void startBtn_Click(object sender, EventArgs e)
{
string loginUrl = string.Format("{0}/login.aspx ", BBSURL);
RemoveCookies();
MaliciousLogin(loginUrl, USERNAME, PASSWORD);
startBtn.Enabled = false;
}
/// <summary>
/// 自动登录
/// </summary>
public void MaliciousLogin(string loginUrl, string usr, string pwd)
{
string responseHTML = string.Empty; ;
string loginstr = string.Format("username={0}&password={1}&question=0&answer=&expires=43200&templateid=0&login=%E7%99%BB%E5%BD%95", usr, pwd);
loginstr = EncodePost(loginstr);
byte[] replybyte = Encoding.UTF8.GetBytes(loginstr);
try
{
CookieContainer _cookieContainer = new CookieContainer();
BBSRequest = (HttpWebRequest)WebRequest.Create(loginUrl);
BBSRequest.CookieContainer = _cookieContainer;
BBSRequest.ContentType = "application/x-www-form-urlencoded";
BBSRequest.Method = "POST";
//post 开始
BBSRequest.ContentLength = replybyte.Length;
Stream newStream = BBSRequest.GetRequestStream();
newStream.Write(replybyte, 0, replybyte.Length);
newStream.Close();
//post 结束
//返回HTML
BBSResponse = (HttpWebResponse)BBSRequest.GetResponse();
Stream dataStream = BBSResponse.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("utf-8"));
responseHTML = reader.ReadToEnd();
gCookieCollention = BBSResponse.Cookies;
if (responseHTML.IndexOf("登录成功") > 0)
MessageBox.Show("Login successful");
else
MessageBox.Show(responseHTML);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// post 帖子
/// </summary>
private void PostTopic(string forumid, string title, string content)
{
try
{
BBSRequest = (HttpWebRequest)WebRequest.Create(string.Format("{0}/posttopic.aspx?forumid={1}", BBSURL,forumid));
BBSRequest.ContentType = "application/x-www-form-urlencoded";
BBSRequest.Method = "POST";
BBSRequest.Referer = string.Format("{0}/posttopic.aspx?forumid={1}", BBSURL, forumid);
BBSRequest.KeepAlive = true;
BBSRequest.AllowWriteStreamBuffering = false;
BBSRequest.ContentType = "multipart/form-data; boundary=---------------------------7d8182810472";
CookieContainer cookieCon = new CookieContainer();
BBSRequest.CookieContainer = cookieCon;
BBSRequest.CookieContainer.Add(gCookieCollention);
string topicStr = BuildPostContent(title, content);
// string topic = EncodePost(topicStr);
string topic = topicStr;
byte[] replybyte = Encoding.UTF8.GetBytes(topic);
BBSRequest.ContentLength = replybyte.Length;
Stream newStream = BBSRequest.GetRequestStream();
newStream.Write(replybyte, 0, replybyte.Length);
newStream.Close();
// get response
BBSResponse = (HttpWebResponse)BBSRequest.GetResponse();
Stream dataStream = BBSResponse.GetResponseStream();
StreamReader reader = new StreamReader(dataStream, Encoding.GetEncoding("utf-8"));
string responseHTML = reader.ReadToEnd();
reader.Close();
dataStream.Close();
BBSResponse.Close();
if (responseHTML.IndexOf("发表主题成功") > 0)
MessageBox.Show("发表主题成功!");
else
MessageBox.Show(responseHTML);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private string BuildPostContent(string title, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"temppassword/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"question/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"answer/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"title/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(title + "/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"iconid/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"usesig/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("1/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"posteditor_mediatyperadio/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("on/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"message/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(message + "/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"sposteditor_mode/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"restoredata/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("恢复数据/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"previewbutton/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("预览帖子/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"postfile/"; filename=/"/"/r/n");
sb.Append("Content-Type: application/octet-stream/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"localid/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"readperm/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"attachdesc/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"albums/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"postfile/"; filename=/"/"/r/n");
sb.Append("Content-Type: application/octet-stream/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"localid/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("1/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"readperm/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"attachdesc/"/r/n");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"albums/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"topicreadperm/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append(BoundaryString);
sb.Append("Content-Disposition: form-data; name=/"postbytopictype/"/r/n");
sb.Append(Environment.NewLine);
sb.Append("0/r/n");
sb.Append("-----------------------------7d8182810472--");
sb.Append(Environment.NewLine);
return sb.ToString();
}
private string BoundaryString
{
get { return "-----------------------------7d8182810472/r/n"; }
}
private string EncodePost(string input)
{
string output = null;
Char[] reserved = { '?', '=', '&' };
if (input != null)
{
int i = 0, j;
while (i < input.Length)
{
j = input.IndexOfAny(reserved, i);
if (j == -1)
{
output = output + HttpUtility.UrlEncode(input.Substring(i, input.Length - i), System.Text.Encoding.GetEncoding("utf-8"));
break;
}
string tt = HttpUtility.UrlEncode(input.Substring(i, j - i), System.Text.Encoding.GetEncoding("utf-8"));
output += tt;
output += input.Substring(j, 1);
i = j + 1;
}
return output;
}
else
return null;
}
private void btnPost_Click(object sender, EventArgs e)
{
string forumid = txtForumID.Text.Trim();
string title = txtTitle.Text.Trim();
string content = txtContent.Text.Trim();
PostTopic(forumid, title, content);
}
private void RemoveCookies()
{
int cookiesmax = Environment.GetFolderPath(Environment.SpecialFolder.Cookies).Length;
for (int i = 0; i < cookiesmax; i++)
Environment.GetFolderPath(Environment.SpecialFolder.Cookies).Remove(0);
}
}
}
相关推荐
Discuz! .net C# 开源论坛 最终版完全代码
Discuz! 论坛 C# 完全开源版本。非常强大的C# 经典论坛代码,虽然死在4.0版本以前。但是里面包含各类功能非常完善,包含xml,rss,ftp,config,sql,存储过程等等。c# 学习开必备。
c#论坛群发源码|c#论坛自动登录
C#论坛群发之自动登录源码。
C#自动发帖程序 完整项目,C#源代码
C#自动发帖程序 完整项目,C#源代码,以魅族论坛为例进行发帖,已测试。账户(mychange)当前帖子数4700+。
【Discuz】如何实现自动注册登录
本文实现功能: 1.从原有系统进入论坛自动登录和注册 2.实现弹框在本页面,不进行跳转 3.js在页面加载时直接发起注册请求 这个功能之前使用的uc_user_register这个函数来处理的,但是今天在开发用户空间时就会出现问题。 项目需求 在我们原有的系统上添加一个论坛,但是用户信息需要共享。 实现方法:在进入论坛时带上原有系统的用户信息,然后论坛那边拿到信息直接注册即可。 从原有系统进入...
Discuz论坛post登录C#源码
总结: loginhash formhash 表单参数 seccode 参数最重要 全局 的 获取验证码 判断验证码 到最后提交登录 它都有存在 ,seccode==idhash COOKIE自动维护我就不多讲了,自己看demo吧。 下载地址:http://www.test404.com/post-1035.html...
C#模拟登录Discuz论坛 附代码 Discuz X1.5
C#模拟登录Discuz论坛 附代码 Discuz X1.5 本方法通过将账号和密码提交到登录页面,返回一个CookieContainer类型的COOKIE容器,需要模拟登录访问的时候带着这个CookieContainer访问指定地址便可。
C# 自动登录DiscuzNT论坛并发帖
<br />using System;<br />using System.Collections.Generic;<br />using System.ComponentModel;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<br />using System.Windows.Forms;<br />using System.Net;<br />usi
C#dz论坛发帖机Post发帖机源码
C#dz论坛发帖机Post发帖机源码成品取消下载,留源码大家。因为有的论坛版本不同,得到的cookie也不同,这个版本只能原版3.2才能获取,所以取消成品了。软件支持多账号登录发帖。 至于多标题多内容,请各位自行研究,我已经把多账号导入的代码写了 那么导入标题跟内容,你们自己动动手还能搞不定?别的dz论坛类型软件自行看源码修改
c#做的Discuz论坛源代码
一个非常好的c#做的论坛。大家赶紧下啊。
C# BBS论坛系统
C# BBS论坛系统项目源码 基于C#编程BBS论坛系统源码程序,程序员在编程的过程中可以参考学习使用,希望对IT程序员有用,此源码程序简单易懂、方便阅读,有很好的学习价值!
discuz3.5.2 asp.net完全开源适合二次开发
在网上找了很多,都没有找到asp.net discuz版本的,此版本借鉴一个前辈代码,更改一部分,测试有效,适合二次开发。
discuz发帖流程_C#代码、流程discuz论坛批量或自动发帖
用的asp.net+c#来开发个discuz论坛批量或自动发帖的程序,摸索了2,3天,终于成功了。下面是源代码和流程说明:protected void Button8_Click(object sender, EventArgs e){string tl, tr, cl, cr;tl = TBtitleLeft.Text;tr = "\r\n";// TBtitleRigt.Text;cl = "...
ASP.NET二次开发Discuz,单点登录等功能。
ASP.NET二次开发Discuz,单点登录功能,同步注册退出等,
实用C#制作Discuz发帖
private string Post(string url, string postdata) { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"; myHttp
2436




被折叠的 条评论
为什么被折叠?



