Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Runtime.InteropServices;
- namespace IeCookiesGetter
- {
- class Program
- {
- [DllImport("wininet.dll", SetLastError = true)]
- public static extern bool InternetGetCookie(
- string lpszUrl,
- string lpszCookieName,
- StringBuilder lpszCookieData,
- ref int lpdwSize
- );
- [DllImport("wininet.dll", SetLastError = true)]
- public static extern bool InternetGetCookieEx(
- string lpszURL,
- string lpszCookieName,
- StringBuilder lpszCookieData,
- ref int lpdwSize,
- Int32 dwFlags,
- IntPtr lpReserved
- );
- private const Int32 InternetCookieHttponly = 0x2000;
- [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
- public static extern bool InternetSetCookie(
- string lpszUrlName,
- string lpszCookieName,
- string lpszCookieData
- );
- [DllImport("wininet.dll")]
- static extern InternetCookieState InternetSetCookieEx(
- string lpszURL,
- string lpszCookieName,
- string lpszCookieData,
- int dwFlags,
- int dwReserved);
- enum InternetCookieState : int
- {
- COOKIE_STATE_UNKNOWN = 0x0,
- COOKIE_STATE_ACCEPT = 0x1,
- COOKIE_STATE_PROMPT = 0x2,
- COOKIE_STATE_LEASH = 0x3,
- COOKIE_STATE_DOWNGRADE = 0x4,
- COOKIE_STATE_REJECT = 0x5,
- COOKIE_STATE_MAX = COOKIE_STATE_REJECT
- }
- static void Main(string[] args)
- {
- getCookie("https://www.instagram.com/");
- // setCookie("https://www.instagram.com/", "csrftoken=2h1scGo9cDWSdtfjGZ1ZYdtzEgU5Iv17; mid=WsivtQAEAAG7jsgFzaDM-MM9tcKG; sessionid=IGSCf4180bfa871315dca124753a44cbc4b71c07067c3e425cde5fd2514d27fa147a%3AFpSIYIJOEaaHYc8AOLo8F0zQgB7oCz4u%3A%7B%22_auth_user_id%22%3A1591784797%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22_auth_user_hash%22%3A%22%22%2C%22_platform%22%3A4%2C%22_token_ver%22%3A2%2C%22_token%22%3A%221591784797%3AqIVGwmXImpiwazR7NeLv2xtwIyqcxdhR%3Aef79af92c302726fb3cd80cde75f9525a57a183b1387a8d011bb5d317a782e80%22%2C%22last_refreshed%22%3A1523103088.6970789433%7D; ds_user_id=1591784797" + "; Expires=" + DateTime.Now.AddDays(10).ToString("R"));
- Console.ReadLine();
- }
- public static void getCookie(string domainName)
- {
- int size = 0;
- InternetGetCookieEx(domainName, null, null, ref size, InternetCookieHttponly, IntPtr.Zero);
- // create buffer of correct size
- StringBuilder lpszCookieData = new StringBuilder(size);
- InternetGetCookieEx(domainName, null, lpszCookieData, ref size, InternetCookieHttponly, IntPtr.Zero);
- // get cookie
- string cookie = lpszCookieData.ToString();
- Console.Write(cookie);
- }
- public static void setCookie(string domain, string variables)
- {
- InternetSetCookieEx(domain, null, variables, 0, 0);
- // InternetSetCookie(domain, null, variables);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement