Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/python/Python-2.7.2
- #Steam64 ID - 76561198041707719
- import urllib
- import cgi, cgitb
- import itertools
- import urllib2
- import time
- from datetime import datetime
- from bs4 import BeautifulSoup
- from flask import Flask, jsonify, render_template, redirect
- import requests
- import json
- import xml.etree.ElementTree as ET
- from xml.dom.minidom import parseString
- import sys
- API_KEY = 'XXX'
- API_BASEURL = 'http://api.steampowered.com/'
- API_GET_FRIENDS = API_BASEURL + 'ISteamUser/GetFriendList/v0001/?key='+API_KEY+'&steamid='
- API_GET_SUMMARIES = API_BASEURL + 'ISteamUser/GetPlayerSummaries/v0002/?key='+API_KEY+'&steamids='
- PROFILE_URL = 'http://steamcommunity.com/profiles/'
- phisherusers = ''
- steamIDs = []
- myFriends = []
- phisherids = []
- cgitb.enable()
- form = cgi.FieldStorage()
- steeam = form.getfirst('steamid')
- class steamUser:
- def __init__(self, name, steamid, picture, profileurl, profilestate, isPhisher):
- self.name = name
- self.steamid = steamid
- self.isPhisher = isPhisher
- self.profileurl = profileurl
- if profilestate == 0:
- self.profilestate = '<span style=\"color:#616161\";>(Offline)</span>'
- self.picture = '<img class = \"offline\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- elif profilestate == 1:
- self.profilestate = '<span style=\"color:#006EFF\";>(Online)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- elif profilestate == 2:
- self.profilestate = '<span style=\"color:#006EFF\";>(Busy)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- elif profilestate == 3:
- self.profilestate = '<span style=\"color:#006EFF\";>(Away)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- elif profilestate == 4:
- self.profilestate = '<span style=\"color:#006EFF\";>(Snooze)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- elif profilestate == 5:
- self.profilestate = '<span style=\"color:#006EFF\";>(Looking to Trade)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- else:
- self.profilestate = '<span style=\"color:#006EFF\";>(Looking to Play)</span>'
- self.picture = '<img class = \"border\" src=\"' + picture + '\" title = \"\" alt = \"\">'
- def setPhisherStatus(self, phisher):
- self.isPhisher = phisher
- def toString(self):
- return '<div id = \"phisher-profile\" style = \"width: 33%; float: left; display: block; margin-left: auto; margin-right: auto;\"><h3 style = \"font-size: 30px\">' + self.picture + '</br> </br>' + self.name + '</br>' + self.profilestate + '</br>' + 'Steam ID: ' + self.steamid + '</br>' + '<a href=\"' + self.profileurl + '\">Steam Profile' + '</a></br></br>' + '</h3></div>' + ''
- def getFriendList(steamid):
- for i in range(0, 3):
- try:
- r = requests.get(API_GET_FRIENDS+steamid, timeout=5)
- except:
- continue
- data = r.json()
- for friend in data['friendslist']['friends']:
- steamIDs.append(friend['steamid'])
- return grabPhishers(steamIDs)
- return 'Unable to grab your friend\'s list, please try your request again.'
- def grabPhishers(ids):
- global phisherusers
- for l in chunksiter(ids, 50):
- sids = ','.join(map(str, l))
- if not isPhisher(sids):
- return 'Connection Error: Please try your request again.'
- #remove duplicates
- for fri in myFriends:
- if fri.isPhisher:
- phisherids.append(fri.steamid)
- phisherusers = phisherusers + fri.toString()
- if phisherusers == '':
- return 'User has no phishers!'
- return phisherusers
- def chunksiter(l, chunks):
- i,j,n = 0,0,0
- rl = []
- while n < len(l)/chunks:
- rl.append(l[i:j+chunks])
- i+=chunks
- j+=j+chunks
- n+=1
- return iter(rl)
- def isPhisher(sids):
- for jk in range(0, 3):
- try:
- r = requests.get(API_GET_SUMMARIES+sids, timeout=5)
- except:
- continue
- data = r.json();
- for i in range(len(data['response']['players'])):
- steamFriend = data['response']['players'][i]
- n = steamUser(steamFriend['personaname'], steamFriend['steamid'], steamFriend['avatarfull'], steamFriend['profileurl'], steamFriend['personastate'], False)
- if steamFriend['communityvisibilitystate'] and not steamFriend['personastate']:
- url = PROFILE_URL+steamFriend['steamid']+'?xml=1'
- if 'profilestate' not in steamFriend:
- n.setPhisherStatus(True);
- #phisherusers = phisherusers + n.toString()
- for jjk in range(0, 3):
- try:
- dat = requests.get(url, timeout=5)
- except:
- continue
- if parseString(dat.text.encode('utf8')).getElementsByTagName('privacyState'):
- privacy = str(parseString(dat.text.encode('utf-8')).getElementsByTagName('privacyState')[0].firstChild.wholeText)
- if (privacy == 'private'):
- n.setPhisherStatus(True)
- #phisherusers = phisherusers + n.toString()
- elif 'profilestate' not in steamFriend:
- n.setPhisherStatus(True);
- #phisherusers = phisherusers + n.toString()
- else:
- steamprofile = BeautifulSoup(urllib.urlopen(PROFILE_URL+steamFriend['steamid']).read())
- for row in steamprofile('div', {'class': 'commentthread_comment '}):
- comment = row.find_all('div', 'commentthread_comment_text')[0].get_text().lower()
- if ('phisher' in comment) or ('scammer' in comment):
- n.setPhisherStatus(True)
- #phisherusers = phisherusers + n.toString()
- myFriends.append(n);
- return True
- return "Connection Error: Please try your request again."
- def grabPhisherIDs():
- return ','.join(map(str, phisherids))
- body=("<html><title>Hello</title>" +
- "<body>" +
- "<div id=\"phisher-users\"></br></br>" +
- "%s" +
- "</br></br>" +
- "</div>" +
- "<div id=\"phisher-ids\" style=\"display: none;\">" +
- "%s" +
- "</div>" +
- "</body>" +
- "</html>" % (getFriendList(steeam), grabPhisherIDs()))
- reply=("HTTP/1.1 200 OK\n" +
- "Date: %s\n" +
- "Content-Type: text/html\n" +
- "Content-Length: %s\n" +
- "Connection: close\n" +
- "\n" +
- "%s" % (datetime.datetime.utcnow().isoformat(' '), len(body), body) )
- print reply
- #print "Content-type: text/html\r\n\r\n"
- #print "<div id=\"phisher-users\"></br></br>"
- #print getFriendList(steeam)
- #print "</div>"
- #print "<div id=\"phisher-ids\" style=\"display: none;\">"
- #print grabPhisherIDs()
- #print "</div>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement