Beispiel #1
1
        public static string SendRequest(string method, string url, string userAgent, string Referer, string cookie, string contentType, string[] headernames, string[] headers, string data)
        {
            WinHttp.WinHttpRequest req = new WinHttpRequest();

            try
            {
                req.Open(method, url, true);
                if (String.IsNullOrWhiteSpace(userAgent) == false) req.SetRequestHeader("User-Agent", userAgent);
                if (String.IsNullOrWhiteSpace(Referer) == false) req.SetRequestHeader("Referer", Referer);
                if (String.IsNullOrWhiteSpace(cookie) == false) req.SetRequestHeader("Cookie", cookie);
                if (string.IsNullOrWhiteSpace(contentType) == false) req.SetRequestHeader("Content-Type", contentType);
                for(int i = 0; i <= headernames.Count(); i++)
                {
                    if (string.IsNullOrWhiteSpace(headernames[i]) == false && string.IsNullOrWhiteSpace(headers[i]) == false)
                    {
                        req.SetRequestHeader(headernames[i], headers[i]);
                    }
                }
                req.Send(data);
                req.WaitForResponse();
            }
            catch(Exception ex)
            {
                return "Error : " + ex.Message.Trim();
            }

            return req.ResponseText;
        }
Beispiel #2
0
        private bool CheckCorrectLink()
        {
            if (!this.materialSingleLineTextField1.Text.StartsWith("http://tvple.com/"))
            {
                return(false);
            }
            if (!this.materialSingleLineTextField2.Text.StartsWith("http://api.tvple.com/v1/player/cloud/write?"))
            {
                return(false);
            }
            try
            {
                WinHttpRequest Winhttp = new WinHttpRequest();

                Winhttp.Open("GET", this.materialSingleLineTextField1.Text);
                Winhttp.Send();
                Winhttp.WaitForResponse();
                string result = Encoding.UTF8.GetString(Winhttp.ResponseBody);

                string[] Separators = new string[] { "fa fa-fw fa-television" };
                string[] strResults = result.Split(Separators, StringSplitOptions.None);

                string[] results1  = strResults[1].Split(new string[] { "</span>" }, StringSplitOptions.None);
                string[] size      = results1[1].Split(new string[] { "</li>" }, StringSplitOptions.None);
                string   finalsize = size[0];

                int x = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[0], @"\D", ""));
                int y = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[1], @"\D", ""));
            }
            catch { return(false); }



            return(true);
        }
Beispiel #3
0
 public PostPage()
 {
     InitializeComponent();
     winhttp = new WinHttpRequest();
     PostListView.ItemsSource    = PostListViewModel.GetInstance();
     MaxPageText.DataContext     = PageViewModel.GetInstance();
     PresentPageText.DataContext = PageViewModel.GetInstance();
     // 학사 공지사항을 default로 설정 //
     url = "https://www.koreatech.ac.kr/kor/CMS/NoticeMgr/bachelorList.do";
     PostListModel.SetSource(GetPostList(url, 1));
 }
Beispiel #4
0
 public static bool Login(string id, string pw)
 {
     WinHttpRequest winhttp = new WinHttpRequest();
     winhttp.Open("POST", "https://nid.naver.com/nidlogin.login");
     winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/");
     winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0");
     if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url"))
     {
         return true;
     }
     return false;
 }
        private string php(string url)
        {
            WinHttpRequest win = new WinHttpRequest();

            try
            {
                win.Open("GET", url);
                win.Send();
                win.WaitForResponse();
            }
            catch { MessageBox.Show(this, " Server Connection Error", " Debian "); Environment.Exit(0); }
            return(win.ResponseText);
        }
Beispiel #6
0
        public static bool Login(string id, string pw)
        {
            WinHttpRequest winhttp = new WinHttpRequest();

            winhttp.Open("POST", "https://nid.naver.com/nidlogin.login");
            winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/");
            winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0");
            if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url"))
            {
                return(true);
            }
            return(false);
        }
Beispiel #7
0
        void Send_Cloud(string y, string pos, string text, string x)
        {
            string _text = "text=" + HttpUtility.UrlEncode(text);
            string url   = headerLink.Split('&')[0] + "&" + headerLink.Split('&')[1];

            url += "&text=" + text + "&pos=" + pos + "&x=" + x + "&y=" + y + "&_=" + headerLink.Split('&')[6].Split('=')[1];
            WinHttpRequest Winhttp = new WinHttpRequest();

            Winhttp.Open("GET", url);
            //Winhttp.SetRequestHeader("Cookie", this.textBox1.Text);
            Winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            Winhttp.Send();
            //MessageBox.Show(y + "&" + pos + "&" + text + "&" + x);
            Winhttp.WaitForResponse();
        }
Beispiel #8
0
        private string winhttp(string http, string referer)
        {
            WinHttpRequest win = new WinHttpRequest();

            try
            {
                win.Open("GET", http, true);
                win.SetRequestHeader("Referer", referer);
                win.Send();
                win.WaitForResponse();
            }
            catch { MessageBox.Show(this, "\rServer Connection Error", " Debian "); Environment.Exit(0); }
            string result = Encoding.UTF8.GetString(win.ResponseBody);

            return(result);
        }
Beispiel #9
0
        public static string php(string url)
        {
            WinHttpRequest win = new WinHttpRequest();

            try
            {
                win.Open("GET", url);
                win.Send();
                win.WaitForResponse();
            }
            catch
            {
                MessageBox.Show("Connection Error", "Novah", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
            return(win.ResponseText);
        }
Beispiel #10
0
        private ApiResult UserQuery(string path, HttpMethod http, Dictionary <string, string> headers = null, string content = "", bool jsonContent = false)
        {
            var methodName = http.Method.ToString();
            var winHttp    = new WinHttpRequest();

            path = BaseUri + path;

            if (methodName == "POST" && content.Length == 0)
            {
                throw new ArgumentException("Empty content.");
            }

            if (headers != null && headers.Count == 0)
            {
                throw new ArgumentException("Empty headers.");
            }

            winHttp.Open(methodName, path, true);

            if (http == HttpMethod.Post)
            {
                winHttp.SetRequestHeader("Content-Type", jsonContent ? "application/json" : "application/x-www-form-urlencoded");
            }

            if (headers != null)
            {
                foreach (var header in headers)
                {
                    winHttp.SetRequestHeader(header.Key, header.Value);
                }
            }

            winHttp.Send(content);
            winHttp.WaitForResponse();

            if (winHttp.Status != 200)
            {
                throw new InvalidOperationException(String.Format("{0} {1} {2} {3}", winHttp.StatusText, methodName, path, winHttp.ResponseText));
            }

            ParseResponseHeaders();
            return(new ApiResult(winHttp.Status, winHttp.ResponseText));
        }
Beispiel #11
0
        public static string SendRequest(string method, string url, string userAgent, string Referer, string cookie, string contentType, string[] headernames, string[] headers, string data)
        {
            WinHttp.WinHttpRequest req = new WinHttpRequest();

            try
            {
                req.Open(method, url, true);
                if (String.IsNullOrWhiteSpace(userAgent) == false)
                {
                    req.SetRequestHeader("User-Agent", userAgent);
                }
                if (String.IsNullOrWhiteSpace(Referer) == false)
                {
                    req.SetRequestHeader("Referer", Referer);
                }
                if (String.IsNullOrWhiteSpace(cookie) == false)
                {
                    req.SetRequestHeader("Cookie", cookie);
                }
                if (string.IsNullOrWhiteSpace(contentType) == false)
                {
                    req.SetRequestHeader("Content-Type", contentType);
                }
                for (int i = 0; i <= headernames.Count(); i++)
                {
                    if (string.IsNullOrWhiteSpace(headernames[i]) == false && string.IsNullOrWhiteSpace(headers[i]) == false)
                    {
                        req.SetRequestHeader(headernames[i], headers[i]);
                    }
                }
                req.Send(data);
                req.WaitForResponse();
            }
            catch (Exception ex)
            {
                return("Error : " + ex.Message.Trim());
            }

            return(req.ResponseText);
        }
Beispiel #12
0
 public void Create(string HttpAddress, string FolderName, int count)
 {
     if (HttpAddress.IndexOf("http") > -1 | HttpAddress.IndexOf("https") > -1)
     {
         Random         rr = new Random();
         WinHttpRequest wt = new WinHttpRequest();
         for (int i = 0; i < count; i++)
         {
             wt.Open("GET", HttpAddress + "?action=MakeDirectory&name=" + FolderName + "_" + DateTime.Now.ToString("mmssff"));
             wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/" + rr.Next(0, 8088));
             wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
             wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
             wt.SetRequestHeader("Referer", HttpAddress);
             wt.Send();
             Console.WriteLine("[{0}/{1}] SendOK.", i, count);
         }
     }
     else
     {
         throw new Exception("http 또는 https 를 포함해야 합니다.");
     }
 }
Beispiel #13
0
        void Get_Size(string link)
        {
            WinHttpRequest Winhttp = new WinHttpRequest();

            Winhttp.Open("GET", link);
            Winhttp.Send();
            Winhttp.WaitForResponse();
            string result = Encoding.UTF8.GetString(Winhttp.ResponseBody);

            string[] Separators = new string[] { "fa fa-fw fa-television" };
            string[] strResults = result.Split(Separators, StringSplitOptions.None);

            string[] results1  = strResults[1].Split(new string[] { "</span>" }, StringSplitOptions.None);
            string[] size      = results1[1].Split(new string[] { "</li>" }, StringSplitOptions.None);
            string   finalsize = size[0];

            int x = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[0], @"\D", ""));
            int y = Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(finalsize.Split('x')[1], @"\D", ""));

            this.screen_Size         = new System.Drawing.Size(x, y);
            this.materialLabel3.Text = "Video Size : (" + x.ToString() + "," + y.ToString() + ")";
        }
Beispiel #14
0
 public static int GET_NOTI_COUNT(string id, string pw)
 {
     try
     {
         WinHttpRequest winhttp = new WinHttpRequest();
         winhttp.Open("POST", "https://nid.naver.com/nidlogin.login");
         winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/");
         winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
         winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0");
         if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url"))
         {
             winhttp.Open("GET", "http://my.naver.com/");
             winhttp.Send();
             string[] result = winhttp.ResponseText.Split(new string[] { "\"noti\":" }, StringSplitOptions.None);
             int NOTI_COUNT = Convert.ToInt32(result[1].Split(',')[0]);
             return NOTI_COUNT;
         }
         return 0;
     }
     catch
     {
         return 0;
     }
 }
Beispiel #15
0
 public static int GET_NOTI_COUNT(string id, string pw)
 {
     try
     {
         WinHttpRequest winhttp = new WinHttpRequest();
         winhttp.Open("POST", "https://nid.naver.com/nidlogin.login");
         winhttp.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login?svctype=262144&url=http://m.naver.com/aside/");
         winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
         winhttp.Send("id=" + id + "&pw=" + pw + "&saveID=0&enctp=2&smart_level=-1&svctype=0");
         if (winhttp.ResponseText.Contains("https://nid.naver.com/login/sso/finalize.nhn?url"))
         {
             winhttp.Open("GET", "http://my.naver.com/");
             winhttp.Send();
             string[] result     = winhttp.ResponseText.Split(new string[] { "\"noti\":" }, StringSplitOptions.None);
             int      NOTI_COUNT = Convert.ToInt32(result[1].Split(',')[0]);
             return(NOTI_COUNT);
         }
         return(0);
     }
     catch
     {
         return(0);
     }
 }
Beispiel #16
0
        public bool Post(string NaverID, string NaverPW, string title, string content, int category)
        {
            try
            {
                content = HttpUtility.UrlEncode(content, Encoding.GetEncoding(949));
                title   = HttpUtility.UrlEncode(title, Encoding.GetEncoding(949));
                WinHttpRequest ht = new WinHttpRequest();
                ht.Open("POST", "https://nid.naver.com/nidlogin.login");
                ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                ht.SetRequestHeader("Referer", "https://nid.naver.com/nidlogin.login");
                ht.Send("enctp=2&url=http://www.naver.com&enc_url=http://www.naver.com&postDataKey=&saveID=0&nvme=0&smart_level=1&id=" + NaverID + "&pw=" + NaverPW);
                ht.WaitForResponse();
                string[] cookie      = ht.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None);
                int      cookieCount = 0;
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        cookieCount++;
                    }
                }
                String[] cookies = new String[cookieCount];
                cookieCount = 0;
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        String cookie1 = header.Replace("Set-Cookie: ", "");
                        cookies[cookieCount] = cookie1;
                    }
                }
                string Fcookie = "";

                foreach (string cds in cookies)
                {
                    Fcookie += cds;
                }
                //로그인 종료

                ht.Open("GET", "http://blog.naver.com/PostWriteForm.nhn?blogId=" + NaverID + "&Redirect=Write&useSmartEditorVersion=2&redirect=Write&widgetTypeCall=true");
                ht.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                ht.SetRequestHeader("Cookie", Fcookie);
                ht.SetRequestHeader("Host", "blog.naver.com");
                ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "?Redirect=Write");
                ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                ht.Send();
                string blogNo       = Regex.Split(Regex.Split(ht.ResponseText, "var blogNo = '")[1], "';")[0];
                string nowYear      = Regex.Split(Regex.Split(ht.ResponseText, "var nowYear = \"")[1], "\";")[0];
                string nowMount     = Regex.Split(Regex.Split(ht.ResponseText, "var nowMonth = \"")[1], "\";")[0];
                string nowDate      = Regex.Split(Regex.Split(ht.ResponseText, "var nowDate = \"")[1], "\";")[0];
                string nowHour      = Regex.Split(Regex.Split(ht.ResponseText, "var nowHour = \"")[1], "\";")[0];
                string nowMinute    = Regex.Split(Regex.Split(ht.ResponseText, "var nowMinute = \"")[1], "\";")[0];
                string editorSource = Regex.Split(Regex.Split(ht.ResponseText, "name=\"editorSource\" value=\"")[1], "\">")[0];

                ht.Open("POST", "http://blog.naver.com/TempPostWriteAsync.nhn");
                ht.SetRequestHeader("Accept", "*/*");
                ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                ht.SetRequestHeader("Cookie", Fcookie);
                ht.SetRequestHeader("Host", "blog.naver.com");
                ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "/postwrite");
                ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                string postdata = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=&post.sourceCode=0&post.contents.contentsValue=" + content + "&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=true&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=%0A%0A&query=%EC%A7%80%EC%97%AD%EB%AA%85%EC%9D%84%20%EC%9E%85%EB%A0%A5%ED%95%B4%20%EC%A3%BC%EC%84%B8%EC%9A%94&char_preview=%C2%AE%C2%BA%E2%8A%86%E2%97%8F%E2%97%8B&se2_tbp=on&se2_tbp3=on&=on&post.directorySeq=0&post.tag.names=%ED%83%9C%EA%B7%B8%EC%99%80%20%ED%83%9C%EA%B7%B8%EB%8A%94%20%EC%89%BC%ED%91%9C%EB%A1%9C%20%EA%B5%AC%EB%B6%84%ED%95%98%EB%A9%B0%2C%2010%EA%B0%9C%EA%B9%8C%EC%A7%80%20%EC%9E%85%EB%A0%A5%ED%95%98%EC%8B%A4%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.&openType=2&post.postWriteTimeType=now&prePostDay=" + DateTime.Now.ToString("yyyy년 MM월 dd일") + "&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=&prePostDateType.month=&prePostDateType.date=&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D";
                ht.Send(postdata);
                string postlogNo = ht.ResponseText;

                ht.Open("POST", "http://blog.naver.com/PostWrite.nhn");
                ht.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                ht.SetRequestHeader("Accept-Encoding", "deflate");
                ht.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                ht.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                ht.SetRequestHeader("Cookie", Fcookie);
                ht.SetRequestHeader("Host", "blog.naver.com");
                ht.SetRequestHeader("Referer", "http://blog.naver.com/" + NaverID + "/postwrite");
                ht.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                //string postdata2 = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=" + postlogNo + "&post.sourceCode=0&post.contents.contentsValue=<p>" + content + "</p>&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=true&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=<p>" + content + "</p>&query=%C1%F6%BF%AA%B8%ED%C0%BB+%C0%D4%B7%C2%C7%D8+%C1%D6%BC%BC%BF%E4&char_preview=%A2%E7%A8%AC%A1%F6%A1%DC%A1%DB&se2_tbp=on&se2_tbp3=on&post.directorySeq=0&post.tag.names=&openType=2&post.postWriteTimeType=now&prePostDay=2016%B3%E2+5%BF%F9+18%C0%CF&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=" + nowYear + "&prePostDateType.month=" + nowMount + "&prePostDateType.date=" + nowDate + "&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D";
                string postdata2 = "captchaKey=&captchaValue=&appId=&tempLogNo=&blogId=" + NaverID + "&post.logNo=" + postlogNo + "&post.sourceCode=0&post.contents.contentsValue=" + content + "&post.prePostRegistDirectly=false&post.lastRelayTime=&smartEditorVersion=2&post.book.ratingScore=0&post.music.ratingScore=0&post.movie.ratingScore=0&post.scrapedYn=false&post.clientType=&post.contents.summaryYn=false&post.contents.summaryToggleText=&post.contents.summaryTogglePosition=&post.templatePhoto.width=0&post.templatePhoto.height=0&post.addedInfoSet.addedInfoStruct=&post.mapAttachmentSet.mapAttachStruct=&post.calendarAttachmentSet.calendarAttachmentStruct=&post.musicPlayerAttachmentSet.musicPlayerAttachmentStruct=&post.eventWriteInfo.eventCode=&post.eventWriteInfo.writeCode=&post.eventWriteInfo.eventType=&post.eventWriteInfo.eventLink=&post.postOptions.openType=2&post.postOptions.commentYn=true&post.postOptions.isRelayOpen=&post.postOptions.sympathyYn=false&post.postOptions.outSideAllowYn=true&post.me2dayPostingYn=&post.facebookPostingYn=false&post.twitterPostingYn=false&post.postOptions.searchYn=true&post.postOptions.rssOpenYn=true&post.postOptions.scrapType=2&post.postOptions.ccl.commercialUsesYn=false&post.postOptions.ccl.contentsModification=&post.postOptions.noticePostYn=false&directorySeq=0&directoryDetail=&post.bookTheme.infoPk=&post.movieTheme.infoPk=&post.musicTheme.infoPk=&post.kitchenTheme.recipeName=&post.postOptions.directoryOptions.directoryChangeYn=false&post.postOptions.directoryOptions.tagAutoChangedYn=false&post.postOptions.isAutoTaggingEnabled=true&post.postOptions.greenReviewBannerYn=false&previewGreenReviewBannerAsInteger=0&post.leverageOptions.themeSourceCode=&post.music.subType=&post.postOptions.isContinueSaved=false&post.mrBlogTalk.talkCode=&happyBeanGiveDayReqparam=&post.postOptions.isExifEnabled=false&editorSource=" + editorSource + "&post.category.categoryNo=" + category.ToString() + "&post.title=" + title + "&ir1=" + content + "&query=%C1%F6%BF%AA%B8%ED%C0%BB+%C0%D4%B7%C2%C7%D8+%C1%D6%BC%BC%BF%E4&char_preview=%A2%E7%A8%AC%A1%F6%A1%DC%A1%DB&se2_tbp=on&se2_tbp3=on&post.directorySeq=0&post.tag.names=&openType=2&post.postWriteTimeType=now&prePostDay=2016%B3%E2+5%BF%F9+22%C0%CF&prePostDateType.hour=" + nowHour + "&prePostDateType.minute=" + nowMinute + "&prePostDateType.year=" + nowYear + "&prePostDateType.month=" + nowMount + "&prePostDateType.date=" + nowDate + "&commercialUses=false&contentsModification=0&writingMaterialInfos=%5B%5D";
                ht.Send(postdata2);
                if (ht.ResponseText.IndexOf("refresh") != -1)
                {
                    return(true);
                }
                else
                {
                    if (ht.ResponseText.IndexOf("비정상적") != -1)
                    {
                        Console.WriteLine("[E01] 네이버 블로그서비스 에서 등록거부를 Return 받았습니다.");
                    }
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            WinHttpRequest winhttp = new WinHttpRequest();

            winhttp.Open("POST", "https://portal.koreatech.ac.kr/sso/sso_login.jsp");
            winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            winhttp.Send("user_id=id&user_pwd=pw&RelayState=%2Findex.jsp&id=PORTAL&targetId=PORTAL");
            winhttp.WaitForResponse();
            string WMONID     = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[1], "; ")[0];
            string JSessionID = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[2], " Path")[0];

            winhttp.Open("POST", "https://portal.koreatech.ac.kr/ktp/login/checkLoginId.do");
            winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
            winhttp.SetRequestHeader("Cookie", "WMONID=" + WMONID + "; JSESSIONID=" + JSessionID + " setNowLoginId=id");
            winhttp.Send("login_id=id&login_pwd=pw&login_type=&login_empno=&login_certDn=&login_certChannel=");
            winhttp.WaitForResponse();
            if (Strings.Split(Strings.Split(winhttp.ResponseText, "\"result\":\"")[1], "\"")[0] == "true")
            {
                int      cookie_cnt = Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ").Length - 1;
                string[] cookies    = new string[cookie_cnt];
                for (int i = 0; i < cookie_cnt; i++)
                {
                    cookies[i] = Strings.Split(Strings.Split(winhttp.GetAllResponseHeaders(), "Set-Cookie: ")[i + 1], " Domain")[0];
                }
                winhttp.Open("POST", "https://portal.koreatech.ac.kr/ktp/login/checkSecondLoginCert.do");
                winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                string temp_cookie = WMONID + "; " + JSessionID;
                string re          = temp_cookie;
                for (int i = 0; i < cookie_cnt; i++)
                {
                    temp_cookie += " " + cookies[i];
                }
                winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
                winhttp.SetRequestHeader("Cookie", temp_cookie);

                winhttp.Send("login_id=id");
                winhttp.WaitForResponse();
                re += " setNowLoginId=id;";
                for (int i = 0; i < cookie_cnt; i++)
                {
                    re += " " + cookies[i];
                }
                //re += " kut_login_type=id; Domain=koreatech.ac.kr; Path=/; hostOnly=false;";
                re += " kut_login_type=id;";

                winhttp.Open("POST", "https://portal.koreatech.ac.kr/exsignon/sso/sso_assert.jsp");
                //winhttp.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
                //winhttp.SetRequestHeader("Accept-Encoding","gzip, deflate, br");
                //winhttp.SetRequestHeader("Accept-Language","ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7");
                //winhttp.SetRequestHeader("Cache-Control","max-age=0");
                //winhttp.SetRequestHeader("Connection","keep-alive");
                //winhttp.SetRequestHeader("Content-Length","73");
                winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                winhttp.SetRequestHeader("Cookie", re);
                //winhttp.SetRequestHeader("Host","portal.koreatech.ac.kr");
                //winhttp.SetRequestHeader("Origin", "https://portal.koreatech.ac.kr");
                //winhttp.SetRequestHeader("Referer","https://portal.koreatech.ac.kr/sso/sso_login.jsp");
                //winhttp.SetRequestHeader("Sec-Fetch-Dest","document");
                //winhttp.SetRequestHeader("Sec-Fetch-Mode","navigate");
                //winhttp.SetRequestHeader("Sec-Fetch-Site","same-origin");
                //winhttp.SetRequestHeader("Upgrade-Insecure-Request","1");
                //winhttp.SetRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36");
                winhttp.Send("certUserId=&certLoginId=&certEmpNo=&certType=&secondCert=&langKo=&langEn=");
                winhttp.WaitForResponse();
                Console.WriteLine();
            }
        }
Beispiel #18
0
 public Form1()
 {
     Winhttp = new WinHttpRequest();
     InitializeComponent();
 }
Beispiel #19
0
        public bool Post(string DaumID, string DaumPW, string BlogAddress, string title, string content, int categoryID)
        {
            try
            {
                string Fcookie = "";
                title   = HttpUtility.UrlEncode(title, Encoding.UTF8);
                content = HttpUtility.UrlEncode(content, Encoding.UTF8);
                WinHttpRequest wt = new WinHttpRequest();
                wt.Open("GET", "https://logins.daum.net/accounts/presrp.do?id=" + DaumID + "&srpla=" + DaumPW + "&_=1463758848866");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send();

                string rid   = Regex.Split(Regex.Split(wt.ResponseText, "rid\":\"")[1], "\",\"")[0];
                string srplb = Regex.Split(Regex.Split(wt.ResponseText, "srplb\":\"")[1], "\",\"")[0];

                wt.Open("POST", "https://logins.daum.net/accounts/msrp.do?rid=" + rid + "&srplm1=" + srplb);
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                wt.SetRequestHeader("Referer", "https://logins.daum.net/accounts/msrp.do?rid=" + rid + "&srplm1=" + srplb);
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send("url=http%3A%2F%2Fwww.daum.net%2F&relative=&mobilefull=1&weblogin=1&id=" + DaumID + "&pw=");


                wt.Open("POST", "https://logins.daum.net/accounts/mobile.do");
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                wt.SetRequestHeader("Referer", "https://logins.daum.net/accounts/loginform.do?mobilefull=1&url=http%3A%2F%2Fm.daum.net%3Fnil_rc%3DKZXd2c");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send("url=http%3A%2F%2Fm.daum.net%3Fnil_rc%3DKZXd2c&relative=&mobilefull=1&weblogin=1&id=" + DaumID + "&pw=" + DaumPW);

                string log = wt.GetResponseHeader("X-DaumLogin-Error");
                if (log.IndexOf("200") == -1)
                {
                    throw new Exception("올바르지 않은 ID 입니다.");
                }

                string[] cookie      = wt.GetAllResponseHeaders().Split(new string[] { "\n" }, StringSplitOptions.None);
                int      cookieCount = 0;
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        cookieCount++;
                    }
                }
                String[] cookies = new String[cookieCount];
                cookieCount = 0;
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        String cookie1 = header.Replace("Set-Cookie: ", "");
                        Fcookie += cookie1;
                        cookies[cookieCount] = cookie1;
                    }
                }

                foreach (string cds in cookies)
                {
                    Fcookie += cds;
                }

                string TS     = "TS=\"" + Regex.Split(Regex.Split(Fcookie, "TS=")[1], ";")[0] + "\";";
                string HTS    = "HTS=\"" + Regex.Split(Regex.Split(Fcookie, "HTS=")[1], ";")[0];
                string HM_CU  = "HM_CU=\"" + Regex.Split(Regex.Split(Fcookie, "HM_CU=")[1], ";")[0] + "\";";
                string PROF   = "PROF=\"" + Regex.Split(Regex.Split(Fcookie, "PROF=")[1], ";")[0] + "\";";
                string ALID   = "ALID=\"" + Regex.Split(Regex.Split(Fcookie, "ALID=")[1], ";")[0] + "\";";
                string ALCT   = "ALCT=\"" + Regex.Split(Regex.Split(Fcookie, "ALCT=")[1], ";")[0] + "\";";
                string LSID   = "LSID=\"" + Regex.Split(Regex.Split(Fcookie, "LSID=")[1], ";")[0] + "\";";
                string AGEN   = "AGEN=\"" + Regex.Split(Regex.Split(Fcookie, "AGEN=")[1], ";")[0] + "\";";
                string SLEVEL = "SLEVEL=\"" + Regex.Split(Regex.Split(Fcookie, "SLEVEL=")[1], ";")[0] + "\";";
                Fcookie = "";
                Fcookie = TS + HTS + HM_CU + PROF + ALID + ALCT + LSID + AGEN + SLEVEL;

                wt.Open("GET", "http://blog.daum.net/" + BlogAddress);
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send();
                string blogid = Regex.Split(Regex.Split(wt.ResponseText, "blogid=")[1], "&")[0];

                wt.Open("GET", "http://blog.daum.net/_blog/BlogTypeMain.do?blogid=" + blogid.Trim() + "&admin=");
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send();
                string articleOpen = Regex.Split(Regex.Split(wt.ResponseText, "articleopen != \"")[1], "\" ")[0];

                wt.Open("POST", "http://blog.daum.net/_blog/SimpleEditor.do?blogid=" + blogid.Trim());
                wt.SetRequestHeader("Accept", "*/*");
                wt.SetRequestHeader("charset", "utf-8");
                wt.SetRequestHeader("Cookie", Fcookie);
                wt.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                wt.SetRequestHeader("Referer", "http://www.daum.net/dsp/blog/_blog/_top/hdn/myBlogNewsListForDaumTopNew.do");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send("articleTitle=" + title + "&article=" + content + "&articleOpen=" + articleOpen + "&categoryID=" + categoryID + "&formName=articleTypeList");
                return(true);
            }
            catch
            {
                throw new Exception("프로그램 오류가 발생 하였습니다.\n(로그인오류 또는 블로그 서비스 이상)");
            }
        }
        public string KR(string English)
        {
            try
            {
                WinHttpRequest wt = new WinHttpRequest();
                wt.Open("POST", "https://www.bing.com/translator");
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                wt.SetRequestHeader("Content-Type", "text/html; charset=utf-8");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send();
                string[] cookie      = wt.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None);
                int      cookieCount = 0;
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        cookieCount++;
                    }
                }
                String[] cookies = new String[cookieCount];
                cookieCount = 0;
                string Fcookie = "";
                foreach (String header in cookie)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        String cookie1 = header.Replace("Set-Cookie: ", "");
                        cookies[cookieCount] = cookie1;
                        Fcookie += cookie1;
                    }
                }
                string mtstkn  = "mtstkn=" + Regex.Split(Regex.Split(Fcookie, "mtstkn=")[1], ";")[0] + ";";
                string _EDGE_S = "_EDGE_S=" + Regex.Split(Regex.Split(Fcookie, "_EDGE_S=")[1], ";")[0] + ";";
                string EDGE_V  = "_EDGE_V=" + Regex.Split(Regex.Split(Fcookie, "_EDGE_V=")[1], ";")[0] + ";";
                string MUID    = "MUID=" + Regex.Split(Regex.Split(Fcookie, "MUID=")[1], ";")[0] + ";";
                string MUIDB   = "MUIDB=" + Regex.Split(Regex.Split(Fcookie, "MUIDB=")[1], ";")[0] + ";";
                Fcookie = ""; Fcookie = mtstkn + _EDGE_S + EDGE_V + MUID + MUIDB;

                wt.Open("GET", "https://www.bing.com/secure/Passport.aspx?popup=1&ssl=1");
                wt.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
                wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                wt.SetRequestHeader("Content-Type", "text/html; charset=utf-8");
                wt.SetRequestHeader("Cookie", Fcookie);
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send();
                string[] cookie2      = wt.GetAllResponseHeaders().Split(new string[] { "\r\n" }, StringSplitOptions.None);
                int      cookieCount2 = 0;
                foreach (String header in cookie2)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        cookieCount2++;
                    }
                }
                String[] cookies2 = new String[cookieCount2];
                cookieCount2 = 0;
                string Fcookie2 = "";
                foreach (String header in cookie2)
                {
                    if (header.StartsWith("Set-Cookie: "))
                    {
                        String cookie1 = header.Replace("Set-Cookie: ", "");
                        cookies2[cookieCount] = cookie1;
                        Fcookie2 += cookie1;
                    }
                }
                string SRCHUID = "SRCHUID=" + Regex.Split(Regex.Split(Fcookie, "SRCHUID=")[0], ";")[1] + ";";
                string SRCHUSR = "******" + Regex.Split(Regex.Split(Fcookie, "SRCHUSR="******";")[1] + ";";
                string _SSSID  = "_SS=SID=" + Regex.Split(Regex.Split(Fcookie, "_SS=SID=")[0], ";")[1] + ";";

                wt.Open("POST", "https://www.bing.com/translator/api/Translate/TranslateArray?from=en&to=ko");
                wt.SetRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
                wt.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
                wt.SetRequestHeader("Content-Type", "application/json; charset=UTF-8");
                wt.SetRequestHeader("Cookie", Fcookie + "destLang=ko; dmru_list=ko; destDia=ko-KR; SRCHD=AF=NOFORM;" + SRCHUID + SRCHUSR + _SSSID + "WLS=C=&N=; srcLang=-; smru_list=; sourceDia=en-US");
                wt.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36");
                wt.Send("[{\"id\":2137,\"text\":\"" + English + "\"}]");
                return(Regex.Split(Regex.Split(wt.ResponseText, "\"text\": \"")[1], "\",")[0]);
            }
            catch
            {
                throw new Exception("시스템오류 발생");
            }
        }
Beispiel #21
0
 public void SetLoginInfo(Form1 newFrom1, WinHttpRequest newItemLoginRequest) // 폼 2 에서 로그인 정보 받기
 {
     form1            = newFrom1;
     itemLoginRequest = newItemLoginRequest; // http 쿼리 저장
 }
Beispiel #22
0
 public void SetLoginInfo(Form1 form1, WinHttpRequest newNaverLoginRequest, WinHttpRequest newItemLoginRequest) // 폼 1 에서 로그인 정보 받기
 {
     // http 쿼리 저장
     naverLoginRequest = newNaverLoginRequest;
     itemLoginRequest  = newItemLoginRequest;
 }