Help NPP Cookie

04/28/2014 18:34 Alliance™#1
After few month i return back...I see which nexon change server structure and use SSL for authentication on web site.
This is my old code which i use for get NPP Cookie but now don't work i think for SSL encryption.

Code:
string cookieval = string.Empty;
                string s = "{\"account\":{\"userId\":\"" + HttpUtility.UrlEncode(username) + "\",\"password\":\"" + HttpUtility.UrlEncode(password) + "\",\"accessedGame\":\"Warrock\",\"captcha\":\"\",\"isSaveID\":false}}";

                CookieContainer webCookieContainer = new CookieContainer();
                HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri("https://passport.nexoneu.com/Service/....."));
                webRequest.CookieContainer = webCookieContainer;
                webRequest.KeepAlive = true;
                webRequest.Method = "POST";
                webRequest.ContentType = "application/json;";
                webRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36";
                webRequest.Timeout = 20000;
                webRequest.ContentLength = s.Length;
                webRequest.Proxy = null;

                using (Stream wr = webRequest.GetRequestStream())
                {
                    byte[] stringa = Encoding.ASCII.GetBytes(s);
                    wr.Write(stringa, 0, stringa.Length);
                    wr.Close();

                }
               

                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
                using (StreamReader read = new StreamReader(webResponse.GetResponseStream()))
                {
                    string content = read.ReadToEnd();
                    MessageBox.Show(content);

                }
When i send data i riceve this response:
[Only registered and activated users can see links. Click Here To Register...]

There is one can help me to try to resolve this first problem?Thanks.
04/28/2014 19:09 daniel547#2
maybe you can sniff the new packet and change it in your source
04/28/2014 19:24 Alliance™#3
packet data send is the same...:S
04/28/2014 19:36 wa-sta#4
Even though you are a "CLB coder!", you should just turn on Fiddler or Wireshark and check whats going on.. ;)
04/28/2014 19:43 Alliance™#5
lol?
I open this topic because i already sniff with Fiddler and Wireshark...
04/28/2014 19:43 -ToXiiC#6
ez u have to read before normal cookies
04/28/2014 19:55 Alliance™#7
Don't work
04/28/2014 20:07 wa-sta#8
Quote:
Originally Posted by Alliance™ View Post
lol?
I open this topic because i already sniff with Fiddler and Wireshark...
So what is your issue? You see whats going on so implement it.
04/28/2014 20:12 Alliance™#9
My issue is this:

[Only registered and activated users can see links. Click Here To Register...]

I read the normal cookie first and after send data but dont work...
04/28/2014 20:13 -ToXiiC#10
1) WebRequest on Nexon main webpage, store cookie in the container
2) WebRequest login on [Only registered and activated users can see links. Click Here To Register...] with JSON post data
3) Get your NPP
04/28/2014 20:28 Alliance™#11
i alredy use this method but i dont know why not work :)
04/28/2014 22:30 hero9910#12
Code:
    Public Shared Function loginToWebserver(ByVal Username As String, ByVal Password As String) As String
        Dim str_npp As String = String.Empty
        Dim con_cookieContainer As New CookieContainer

            Dim httpWebRequest As HttpWebRequest = DirectCast(WebRequest.Create("https://passport.nexoneu.com/login/?nexoneuTheme=Warrock"), HttpWebRequest)
            httpWebRequest.KeepAlive = True
            httpWebRequest.Accept = "application/json, text/javascript, */*; q=0.01"
            httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
            httpWebRequest.CookieContainer = con_cookieContainer
            Dim response0 As HttpWebResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)

            Dim Request As HttpWebRequest = CType(WebRequest.Create("https://passport.nexoneu.com/Service/Authentication.asmx/Login"), HttpWebRequest)
            Request.Method = "POST"
            Request.ContentType = "application/json; charset=UTF-8"
            Request.Referer = "https://passport.nexoneu.com/login/?nexoneuTheme=Warrock"
            Request.CookieContainer = con_cookieContainer
            Request.Accept = "application/json, text/javascript, */*; q=0.01"
            Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
            Dim Post As String = "{" + Chr(34) + "account" + Chr(34) + ":{" + Chr(34) + "userId" + Chr(34) + ":" + Chr(34) + Username + Chr(34) + "," + Chr(34) + "password" + Chr(34) + ":" + Chr(34) + Password + Chr(34) + "," + Chr(34) + "accessedGame" + Chr(34) + ":" + Chr(34) + "Warrock" + Chr(34) + "," + Chr(34) + "captcha" + Chr(34) + ":" + Chr(34) + Chr(34) + "," + Chr(34) + "isSaveID" + Chr(34) + ":false}}"

            Dim byteArray() As Byte = Encoding.UTF8.GetBytes(Post)
            Request.ContentLength = byteArray.Length
            Dim DataStream As Stream = Request.GetRequestStream()
            DataStream.Write(byteArray, 0, byteArray.Length)
            DataStream.Close()

            Dim Response1 As HttpWebResponse = CType(Request.GetResponse(), HttpWebResponse)
            DataStream = Response1.GetResponseStream()
            Dim reader As New StreamReader(DataStream)
            reader.Close()
            DataStream.Close()
            Response1.Close()

            For Each CookieFromServer In con_cookieContainer.GetCookies(Request.RequestUri)

                If CookieFromServer.ToString.Contains("NPP=NP12") Then
                    Dim NPP As String() = Split(CookieFromServer.ToString, "=")
                    str_npp = NPP(1)
                    Exit For
                End If

            Next

        If str_npp <> String.Empty Then
            Return str_npp
        Else
            Return String.Empty
        End If

    End Function
04/30/2014 17:17 -ToXiiC#13
Quote:
Originally Posted by hero9910 View Post
Code:
    Public Shared Function loginToWebserver(ByVal Username As String, ByVal Password As String) As String
        Dim str_npp As String = String.Empty
        Dim con_cookieContainer As New CookieContainer

            Dim httpWebRequest As HttpWebRequest = DirectCast(WebRequest.Create("https://passport.nexoneu.com/login/?nexoneuTheme=Warrock"), HttpWebRequest)
            httpWebRequest.KeepAlive = True
            httpWebRequest.Accept = "application/json, text/javascript, */*; q=0.01"
            httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
            httpWebRequest.CookieContainer = con_cookieContainer
            Dim response0 As HttpWebResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)

            Dim Request As HttpWebRequest = CType(WebRequest.Create("https://passport.nexoneu.com/Service/Authentication.asmx/Login"), HttpWebRequest)
            Request.Method = "POST"
            Request.ContentType = "application/json; charset=UTF-8"
            Request.Referer = "https://passport.nexoneu.com/login/?nexoneuTheme=Warrock"
            Request.CookieContainer = con_cookieContainer
            Request.Accept = "application/json, text/javascript, */*; q=0.01"
            Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
            Dim Post As String = "{" + Chr(34) + "account" + Chr(34) + ":{" + Chr(34) + "userId" + Chr(34) + ":" + Chr(34) + Username + Chr(34) + "," + Chr(34) + "password" + Chr(34) + ":" + Chr(34) + Password + Chr(34) + "," + Chr(34) + "accessedGame" + Chr(34) + ":" + Chr(34) + "Warrock" + Chr(34) + "," + Chr(34) + "captcha" + Chr(34) + ":" + Chr(34) + Chr(34) + "," + Chr(34) + "isSaveID" + Chr(34) + ":false}}"

            Dim byteArray() As Byte = Encoding.UTF8.GetBytes(Post)
            Request.ContentLength = byteArray.Length
            Dim DataStream As Stream = Request.GetRequestStream()
            DataStream.Write(byteArray, 0, byteArray.Length)
            DataStream.Close()

            Dim Response1 As HttpWebResponse = CType(Request.GetResponse(), HttpWebResponse)
            DataStream = Response1.GetResponseStream()
            Dim reader As New StreamReader(DataStream)
            reader.Close()
            DataStream.Close()
            Response1.Close()

            For Each CookieFromServer In con_cookieContainer.GetCookies(Request.RequestUri)

                If CookieFromServer.ToString.Contains("NPP=NP12") Then
                    Dim NPP As String() = Split(CookieFromServer.ToString, "=")
                    str_npp = NPP(1)
                    Exit For
                End If

            Next

        If str_npp <> String.Empty Then
            Return str_npp
        Else
            Return String.Empty
        End If

    End Function

For Each CookieFromServer In con_cookieContainer.GetCookies(Request.RequestUri)

If CookieFromServer.ToString.Contains("NPP=NP12") Then
Dim NPP As String() = Split(CookieFromServer.ToString, "=")
str_npp = NPP(1)
Exit For
End If

Next



:facepalm:...
04/30/2014 18:18 hero9910#14
Quote:
Originally Posted by -ToXiiC View Post
For Each CookieFromServer In con_cookieContainer.GetCookies(Request.RequestUri)

If CookieFromServer.ToString.Contains("NPP=NP12") Then
Dim NPP As String() = Split(CookieFromServer.ToString, "=")
str_npp = NPP(1)
Exit For
End If

Next



:facepalm:...
What's your problem?
Ok, the split-function is a bit "out of date" but it still working & I know this function from vba.
I can also use the "new" split function.
04/30/2014 19:37 -ToXiiC#15
foreach(Cookie cookie in request.CookieContainer.GetCookies("url"))
{
if(cookie.Name == "NPP")
{
this.NPP = cookie.Value;
break;
}
}