Jump to content

Automatically Change Forum Signature

rm -rf
Go to solution Solved by fizzlesticks,

For various reasons such as Cloudflare, login/session cookies and the signature form in general being lame this is a giant pain in the ass. 

 

But I was bored...so here's a Python script that sets your sig to the current time. You'll need the Requests, BeautifulSoup and cfscrape packages to run it, then just set your username and password at the top of the file. Then you can alter the main function to use some file instead of the current time.

 

 

Spoiler

#! /usr/bin/env python

import requests
import re
import cfscrape
import bs4
import time

SIG_URL = 'https://linustechtips.com/main/settings/signature/'
LOGIN_URL = 'https://linustechtips.com/main/login/'
MAIN_URL = 'https://linustechtips.com/main/'
CSRF_RE = re.compile('csrfKey=(?P<csrf>[0-9A-Za-z]+)')

USERNAME = 'XXX'
PASSWORD = 'XXX'


def _get_csrf(string):
        match = CSRF_RE.search(string)
        if match:
            return match.group('csrf')


def _login(user, password, csrf, cookies):
    data = {'auth': user,
            'csrfKey': csrf,
            'login__standard_submitted': 1,
            'password': password,
            'remember_me': 0,
            'signin_anonymous': 0,
            'signin_anonymous_checkbox': 1}

    res = requests.post(LOGIN_URL, data=data, cookies=cookies)
    if res.status_code == 200:
        return res.history[0].cookies.get_dict()


def _get_sig_form_data(cookies):
    res = requests.get(SIG_URL, cookies=cookies)
    if res.status_code != 200:
        return

    soup = bs4.BeautifulSoup(res.text, 'html.parser')
    return {'MAX_FILE_SIZE': (None, soup.find('input', {'name': 'MAX_FILE_SIZE'})['value']),
            'plupload': (None, soup.find('input', {'name': 'plupload'})['value']),
            'csrfKey': (None, soup.find('input', {'name': 'csrfKey'})['value']),
            'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']),
            'signature_upload': (None, soup.find('input', {'name': 'signature_upload'})['value'])}


def _set_sig(sig, cookies):
    if sig[:3].lower() != '<p>':
        sig = '<p>' + sig + '</p>'

    data = _get_sig_form_data(cookies)
    data['view_sigs_checkbox'] = (None, '1')
    data['form_submitted'] = (None, '1')
    data['signature'] = (None, sig)

    res = requests.post(SIG_URL, files=data, cookies=cookies)
    if res.status_code != 200:
        return False

    return True


def change_sig(sig):
    cookies, _ = cfscrape.get_tokens(LOGIN_URL)

    res = requests.get(MAIN_URL, cookies)
    if res.status_code != 200:
        print('Unabled to connect to LTT.')
        return

    csrf = _get_csrf(res.text)

    if not csrf:
        print('Unable to get CSRF token.')
        return

    cookies['ips4_IPSSessionFront'] = res.cookies['ips4_IPSSessionFront']
    new_cookies = _login(USERNAME, PASSWORD, csrf, cookies)
    if not new_cookies:
        print('Unable to log in.')
        return

    cookies = dict(cookies, **new_cookies)
    if _set_sig(sig, cookies):
        print('Signature updated! Probably...')
    else:
        print('Unable to set signature.')


def main():
    change_sig(str(time.time()))

if __name__ == '__main__':
    main()

 

 

Ahoy Y'all,

I'm planning to code something that will automatically change my signature to the contents of a .txt file on my computer.

I know C++, C#, Java, and Python.

Any ideas how to start this?

1474409643.6492558

Link to comment
Share on other sites

Link to post
Share on other sites

I don't think the forum supports any way of hooking into something like that as far as I'm aware

Link to comment
Share on other sites

Link to post
Share on other sites

For various reasons such as Cloudflare, login/session cookies and the signature form in general being lame this is a giant pain in the ass. 

 

But I was bored...so here's a Python script that sets your sig to the current time. You'll need the Requests, BeautifulSoup and cfscrape packages to run it, then just set your username and password at the top of the file. Then you can alter the main function to use some file instead of the current time.

 

 

Spoiler

#! /usr/bin/env python

import requests
import re
import cfscrape
import bs4
import time

SIG_URL = 'https://linustechtips.com/main/settings/signature/'
LOGIN_URL = 'https://linustechtips.com/main/login/'
MAIN_URL = 'https://linustechtips.com/main/'
CSRF_RE = re.compile('csrfKey=(?P<csrf>[0-9A-Za-z]+)')

USERNAME = 'XXX'
PASSWORD = 'XXX'


def _get_csrf(string):
        match = CSRF_RE.search(string)
        if match:
            return match.group('csrf')


def _login(user, password, csrf, cookies):
    data = {'auth': user,
            'csrfKey': csrf,
            'login__standard_submitted': 1,
            'password': password,
            'remember_me': 0,
            'signin_anonymous': 0,
            'signin_anonymous_checkbox': 1}

    res = requests.post(LOGIN_URL, data=data, cookies=cookies)
    if res.status_code == 200:
        return res.history[0].cookies.get_dict()


def _get_sig_form_data(cookies):
    res = requests.get(SIG_URL, cookies=cookies)
    if res.status_code != 200:
        return

    soup = bs4.BeautifulSoup(res.text, 'html.parser')
    return {'MAX_FILE_SIZE': (None, soup.find('input', {'name': 'MAX_FILE_SIZE'})['value']),
            'plupload': (None, soup.find('input', {'name': 'plupload'})['value']),
            'csrfKey': (None, soup.find('input', {'name': 'csrfKey'})['value']),
            'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']),
            'signature_upload': (None, soup.find('input', {'name': 'signature_upload'})['value'])}


def _set_sig(sig, cookies):
    if sig[:3].lower() != '<p>':
        sig = '<p>' + sig + '</p>'

    data = _get_sig_form_data(cookies)
    data['view_sigs_checkbox'] = (None, '1')
    data['form_submitted'] = (None, '1')
    data['signature'] = (None, sig)

    res = requests.post(SIG_URL, files=data, cookies=cookies)
    if res.status_code != 200:
        return False

    return True


def change_sig(sig):
    cookies, _ = cfscrape.get_tokens(LOGIN_URL)

    res = requests.get(MAIN_URL, cookies)
    if res.status_code != 200:
        print('Unabled to connect to LTT.')
        return

    csrf = _get_csrf(res.text)

    if not csrf:
        print('Unable to get CSRF token.')
        return

    cookies['ips4_IPSSessionFront'] = res.cookies['ips4_IPSSessionFront']
    new_cookies = _login(USERNAME, PASSWORD, csrf, cookies)
    if not new_cookies:
        print('Unable to log in.')
        return

    cookies = dict(cookies, **new_cookies)
    if _set_sig(sig, cookies):
        print('Signature updated! Probably...')
    else:
        print('Unable to set signature.')


def main():
    change_sig(str(time.time()))

if __name__ == '__main__':
    main()

 

 

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, fizzlesticks said:

For various reasons such as Cloudflare, login/session cookies and the signature form in general being lame this is a giant pain in the ass. 

 

But I was bored...so here's a Python script that sets your sig to the current time. You'll need the Requests, BeautifulSoup and cfscrape packages to run it, then just set your username and password at the top of the file. Then you can alter the main function to use some file instead of the current time.

 

 

  Reveal hidden contents


#! /usr/bin/env python

import requests
import re
import cfscrape
import bs4
import time

SIG_URL = 'https://linustechtips.com/main/settings/signature/'
LOGIN_URL = 'https://linustechtips.com/main/login/'
MAIN_URL = 'https://linustechtips.com/main/'
CSRF_RE = re.compile('csrfKey=(?P<csrf>[0-9A-Za-z]+)')

USERNAME = 'XXX'
PASSWORD = 'XXX'


def _get_csrf(string):
        match = CSRF_RE.search(string)
        if match:
            return match.group('csrf')


def _login(user, password, csrf, cookies):
    data = {'auth': user,
            'csrfKey': csrf,
            'login__standard_submitted': 1,
            'password': password,
            'remember_me': 0,
            'signin_anonymous': 0,
            'signin_anonymous_checkbox': 1}

    res = requests.post(LOGIN_URL, data=data, cookies=cookies)
    if res.status_code == 200:
        return res.history[0].cookies.get_dict()


def _get_sig_form_data(cookies):
    res = requests.get(SIG_URL, cookies=cookies)
    if res.status_code != 200:
        return

    soup = bs4.BeautifulSoup(res.text, 'html.parser')
    return {'MAX_FILE_SIZE': (None, soup.find('input', {'name': 'MAX_FILE_SIZE'})['value']),
            'plupload': (None, soup.find('input', {'name': 'plupload'})['value']),
            'csrfKey': (None, soup.find('input', {'name': 'csrfKey'})['value']),
            'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']),
            'signature_upload': (None, soup.find('input', {'name': 'signature_upload'})['value'])}


def _set_sig(sig, cookies):
    if sig[:3].lower() != '<p>':
        sig = '<p>' + sig + '</p>'

    data = _get_sig_form_data(cookies)
    data['view_sigs_checkbox'] = (None, '1')
    data['form_submitted'] = (None, '1')
    data['signature'] = (None, sig)

    res = requests.post(SIG_URL, files=data, cookies=cookies)
    if res.status_code != 200:
        return False

    return True


def change_sig(sig):
    cookies, _ = cfscrape.get_tokens(LOGIN_URL)

    res = requests.get(MAIN_URL, cookies)
    if res.status_code != 200:
        print('Unabled to connect to LTT.')
        return

    csrf = _get_csrf(res.text)

    if not csrf:
        print('Unable to get CSRF token.')
        return

    cookies['ips4_IPSSessionFront'] = res.cookies['ips4_IPSSessionFront']
    new_cookies = _login(USERNAME, PASSWORD, csrf, cookies)
    if not new_cookies:
        print('Unable to log in.')
        return

    cookies = dict(cookies, **new_cookies)
    if _set_sig(sig, cookies):
        print('Signature updated! Probably...')
    else:
        print('Unable to set signature.')


def main():
    change_sig(str(time.time()))

if __name__ == '__main__':
    main()

 

 

Getting these errors:

Traceback (most recent call last):
  File "file.py", line 98, in <module>
    main()
  File "file.py", line 95, in main
    change_sig(str(time.time()))
  File "file.py", line 88, in change_sig
    if _set_sig(sig, cookies):
  File "file.py", line 55, in _set_sig
    data = _get_sig_form_data(cookies)
  File "file.py", line 47, in _get_sig_form_data
    'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']),
TypeError: 'NoneType' object is not subscriptable

 

1474409643.6492558

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, rm -rf said:

Getting these errors:


Traceback (most recent call last):
  File "file.py", line 98, in <module>
    main()
  File "file.py", line 95, in main
    change_sig(str(time.time()))
  File "file.py", line 88, in change_sig
    if _set_sig(sig, cookies):
  File "file.py", line 55, in _set_sig
    data = _get_sig_form_data(cookies)
  File "file.py", line 47, in _get_sig_form_data
    'view_sigs': (None, soup.find('input', {'name': 'view_sigs'})['value']),
TypeError: 'NoneType' object is not subscriptable

 

Interesting...the only reason I can think of that you'd be getting that error is if your signature changing page is different than mine or you're getting redirected differently. Could you go to this page https://linustechtips.com/main/settings/signature/ copy the source and post it somewhere.

 

edit: better yet if you could add the line 

print(res.text)

before the line

soup = bs4.BeautifulSoup(res.text, 'html.parser')

and post that output.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, fizzlesticks said:

Interesting...the only reason I can think of that you'd be getting that error is if your signature changing page is different than mine or you're getting redirected differently. Could you go to this page https://linustechtips.com/main/settings/signature/ copy the source and post it somewhere.

 

edit: better yet if you could add the line 


print(res.text)

before the line


soup = bs4.BeautifulSoup(res.text, 'html.parser')

and post that output.

It's working now, I just had to turn off my two factor authentication.

1474409643.6492558

Link to comment
Share on other sites

Link to post
Share on other sites

32 minutes ago, rm -rf said:

It's working now, I just had to turn off my two factor authentication.

Good to hear. Also, if this is the program that you're trying to run hidden, you can start a Python script using pythonw.exe instead of python.exe and it will run without popping up a new window.

1474412270.2748842

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×