Esempio n. 1
0
    def f_grab_cmd_from_twitter_profile(profile_name):
        """grab 0xXXXXXXXX tag from profile, tag must match [a-zA-Z0-9_]
        :rtype: string
        :param profile_name: twitter profile name without leading @
        :return: string embedded in the profile description
        """
        url = 'https://twitter.com/%(profile)s'
        payload = {'profile': profile_name}
        html = requests.get(url % payload)
        soup = soupy(html.text)
        profile_description = soup.find('meta',
                                        {'name': 'description'})['content']
        match = re.search('0x(\w+)', profile_description)
        output = match.group(1)  # group 1 consists of match between ( )

        return str(output)
def parseTwitterConnectionData():
    html = urllib.urlopen('https://twitter.com/d_schwenk').read()
    soup = soupy(html)

    x = soup.find("meta", {"name": "description"})['content']

    # x will be something like
    # Die neuesten Tweets von Daniel Schwenk (@d_schwenk): "hello from x"

    # use regex to get string (tweet) between '"'
    filter = re.findall(r'"(.*?)"', x)
    data = filter[0]

    # verify tweet / data contains ip and port (e.g. 192.168.100.100:8080)
    if re.search(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{4}', data):
        data = data.split(':')
        ip = data[0]
        port = int(data[1])
        return (ip, port)
    else:
        # could not get tweet or parse it correctyl, return false values
        return (0, 0)
Esempio n. 3
0
Use it on your own risk. 
'''

# Python For Offensive PenTest: A Complete Practical Course - All rights reserved
# Follow me on LinkedIn  https://jo.linkedin.com/in/python2

#BeautifulSoup 3.2.1 download link
#https://pypi.python.org/pypi/BeautifulSoup

#Case study – Russian Malware
#https://www2.fireeye.com/APT29-HAMMERTOSS-WEB-2015-RPT.html
#https://www.fireeye.com/blog/threat-research/2015/07/hammertoss_stealthy.html

from BeautifulSoup import BeautifulSoup as soupy
import urllib
import re

html = urllib.urlopen('https://twitter.com/tferriss').read()
soup = soupy(html)
#Navigate to my twitter home page HussamKhrais, store the HTML page into html variable and pass it
#to soupy function so we can parse it

x = soup.find("meta", {"name": "description"})['content']
#Here we search for specific HTML meta tags, please see the video to know how did i find these parameters :)

filter = re.findall(
    r'"(.*?)"', x
)  # After parsing the html page, our tweet is located between double quotations
tweet = filter[0]  # using regular expression we filter out the tweet
print tweet