Skip to content

Commit

Permalink
Merge pull request #1 from mpgn/dev
Browse files Browse the repository at this point in the history
Merge dev branch into master
  • Loading branch information
mpgn authored Aug 11, 2017
2 parents d63dd64 + 4a383a4 commit a894881
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 32 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# HallOfFame
# HallOfFame Root-me

Hall Of Fame dashboard for Root-me.org. All users are manually added to the file `users.json`, then with a cron job, the script `update.py` do the rest.
Hall Of Fame dashboard for Root-me.org. Users information are in the `users.json`.

![screenshot](https://i.gyazo.com/1823b9244ef0c4c98d5877f837880dda.png)
![screenshot](https://i.gyazo.com/56b4c6fcc5c5306e3d904735c0716835.png)

## Informations

Expand All @@ -12,12 +12,13 @@ Since root-me doesn't have any API, this is dirty parsing ! But it's working ;)

Add the user in the `users.json` like this :
```
python update.py 'username' 'realname'
python update.py username realname
```
You can get the useranme form the url of a Root-me profile : https://www.root-me.org/username

Update the json like this :
Update the json like this :
```
python3 update.py
python3 update.py update
```

Use a cron job to update the script every night ;)
Expand Down
73 changes: 55 additions & 18 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,48 @@
border-bottom: 0rem solid #727e96;
}
.bar .bar-item {
background: #73d019;
background: #9acc14;
}
.bar {
background: #4e4e4e;
}
tbody tr:first-child td .tile .tile-content:before {
font-family: FontAwesome;
content: "\f005 " !important;
color: #ffb860;
}
</style>
</head>
<body style="background: #232323;color:#c3c3c3;">
<header class="navbar" style="background: #171717;">
<section class="navbar-section">
<!-- <a href="#" class="navbar-brand mr-10">Spectre.css</a>
<a href="#" class="btn btn-link">Docs</a>
<a href="https://github.com/picturepan2/spectre" class="btn btn-link">GitHub</a> -->
</section>
<section class="navbar-center">
<h2> Hall Of Fame Root-Me </h2>
</section>
<section class="navbar-section">
<div class="input-group input-inline">
<!-- <input class="form-input" type="text" placeholder="search" />
<button class="btn btn-primary input-group-btn">Search</button> -->
</div>
</section>
</header>
<div class="container grid-960">
<div class="columns">
<div class="column col-12 col-xs-12 col-sm-12 col-md-12">
<i class="fa fa-trophy" aria-hidden="true"></i> : 100% of challenges flagged in a category &nbsp
<i class="fa fa-star" aria-hidden="true"></i> : Leader of the Hall of Fame
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th style="width: 600px;">Progression</th>
<th>Rank</th>
<th>Overall Points</th>
<tr style="text-align: center;">
<th style="width: 130px;">Name</th>
<th>Challenges</th>
<th style="width: 100px;">Overall</th>
<th style="width: 70px;">Flag</th>
<th style="width: 50px;">Rank</th>
<th style="width: 100px;">Trophy</th>
</tr>
</thead>
<tbody id="content-list">

</tbody>
</table>
</div>
Expand All @@ -68,13 +76,42 @@ <h2> Hall Of Fame Root-Me </h2>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="users.json"></script>
<script type="text/javascript">
$.getJSON("http://halloffame.local/users.json", function( data ) {
/* console.log(data['total_points'])
console.log(data['total_challenge'])*/
$.each( data['users'], function( key, val ) {
//console.log(key, val)
$("#content-list").append('<tr class="text-center"><td><div class="tile tile-centered"><div class="tile-icon"><img src="' + val.avatar + '" class="avatar"></div><div class="tile-content">' + val.username + '</div></div></td><td><div class="bar"><div class="bar-item" role="progressbar" style="width:'+ (val.points*100)/data['total_points'] +'%;" aria-valuenow="'+ (val.points*100)/data['total_points'] +'%" aria-valuemin="0" aria-valuemax="100"></div></div></td><td>' + val.rank + '</td><td>' + val.points + '</td></tr>');
});
$.getJSON("http://halloffame.local:8080/users.json", function( data ) {
data['users'].sort(function(a, b) {
return a.rank - b.rank;
});
data['users'].sort();
console.log(data['users'])
$.each( data['users'], function( key, val ) {
$("#content-list").append(''
+ '<tr class="text-center">'
+ '<td>'
+ '<div class="tile tile-centered tooltip" data-tooltip="'+ val.realn +'"><div class="tile-icon"><img src="' + val.avatar + '" class="avatar">'
+ '</div>'
+ '<div class="tile-content">' + val.username_r + '</div>'
+ '</div>'
+ '</td>'
+ '<td>'
+ '<div class="bar" id="' + val.username_r + '">'
+ '</div>'
+ '</td>'
+ '<td>'
+ '<div class="bar">'
+ '<div class="bar-item tooltip" data-tooltip="'+ val.status + ' ' + val.points + '/'+ data['total_points'] +'" role="progressbar" style="width:'+ (val.points*100)/data['total_points'] +'%;" aria-valuenow="'+ (val.points*100)/data['total_points'] +'%" aria-valuemin="0" aria-valuemax="100">'+ val.points +'</div>'
+ '</div>'
+ '</td>'
+ '<td class="tooltip" data-tooltip="'+ val.challenges + '/' + data['total_challenge'] +'">' + val.challenges + '</td>'
+ '<td>' + val.rank + '</td>'
+ '<td id="trophy_' + val.username_r + '"></td>'
+ '</tr>');
$.each( val['details'], function( key_c, categorie ) {
$("#" + val.username_r).append('<div class="bar-item tooltip" data-tooltip="'+ categorie.name +' ' + categorie.points + ' - ' + (categorie.total - categorie.flag) + ' left" role="progressbar" style="width:' + (categorie.flag*100)/data['total_challenge'] +'%;background:'+ categorie.color +';" aria-valuenow="100%" aria-valuemin="0" aria-valuemax="100"></div>');
if(categorie.flag == categorie.total) {
$("#trophy_" + val.username_r).append('<i class="fa fa-trophy tooltip" data-tooltip="'+ categorie.name +' ' + categorie.points + '" aria-hidden="true" style="color:+ categorie.color +;"></i>');
}

});
});
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion site/users.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"total_points": "11390", "total_challenge": "275", "users": [{"username": "Capitaine-John", "realn": "mpuygrenier", "avatar": "https://www.root-me.org/local/cache-vignettes/L64xH64/auton29499-458aa.jpg", "rank": "159", "points": "5030", "challenges": "180", "status": "programmer"}, {"username": "v1p3r", "realn": "clabro", "avatar": "https://www.root-me.org/local/cache-vignettes/L64xH64/auton9374-f101c.jpg", "rank": "50", "points": "6975", "challenges": "227", "status": "hacker"}]}
{"users": [{"username": "Capitaine-John", "status": "programmer", "realn": "mpuygrenier", "username_r": "bonclay", "points": "5030", "details": [{"name": "App-Script", "total": "12", "flag": "10", "points": "225", "color": "#dbff6b"}, {"name": "App-System", "total": "55", "flag": "16", "points": "495", "color": "#6166ff"}, {"name": "Cracking", "total": "26", "flag": "8", "points": "85", "color": "#ff4141"}, {"name": "Cryptanalysis", "total": "34", "flag": "22", "points": "425", "color": "#b06cfb"}, {"name": "Forensic", "total": "18", "flag": "8", "points": "235", "color": "#35de59"}, {"name": "Progamming", "total": "8", "flag": "5", "points": "55", "color": "#6db8e4"}, {"name": "Realist", "total": "23", "flag": "18", "points": "895", "color": "#ff5887"}, {"name": "Network", "total": "17", "flag": "16", "points": "350", "color": "#e1e0ff"}, {"name": "Steganography", "total": "13", "flag": "10", "points": "155", "color": "#a441ff"}, {"name": "Web-Client", "total": "18", "flag": "17", "points": "575", "color": "#ff84f0"}, {"name": "Web-Server", "total": "51", "flag": "50", "points": "1535", "color": "#35a2ff"}], "challenges": "180", "rank": "159", "avatar": "https://www.root-me.org/local/cache-vignettes/L64xH64/auton29499-458aa.jpg"}, {"username": "v1p3r", "status": "hacker", "realn": "d3mo", "username_r": "v1p3r", "points": "6975", "details": [{"name": "App-Script", "total": "12", "flag": "12", "points": "350", "color": "#dbff6b"}, {"name": "App-System", "total": "55", "flag": "18", "points": "560", "color": "#6166ff"}, {"name": "Cracking", "total": "26", "flag": "23", "points": "630", "color": "#ff4141"}, {"name": "Cryptanalysis", "total": "34", "flag": "31", "points": "755", "color": "#b06cfb"}, {"name": "Forensic", "total": "18", "flag": "18", "points": "665", "color": "#35de59"}, {"name": "Progamming", "total": "8", "flag": "7", "points": "115", "color": "#6db8e4"}, {"name": "Realist", "total": "23", "flag": "21", "points": "1125", "color": "#ff5887"}, {"name": "Network", "total": "17", "flag": "17", "points": "385", "color": "#e1e0ff"}, {"name": "Steganography", "total": "13", "flag": "12", "points": "210", "color": "#a441ff"}, {"name": "Web-Client", "total": "18", "flag": "18", "points": "645", "color": "#ff84f0"}, {"name": "Web-Server", "total": "51", "flag": "50", "points": "1535", "color": "#35a2ff"}], "challenges": "227", "rank": "50", "avatar": "https://www.root-me.org/local/cache-vignettes/L64xH64/auton9374-f101c.jpg"}, {"username": "RainbowLyte", "status": "hacker", "realn": "demo", "username_r": "0deer", "points": "7410", "details": [{"name": "App-Script", "total": "12", "flag": "12", "points": "350", "color": "#dbff6b"}, {"name": "App-System", "total": "55", "flag": "31", "points": "1950", "color": "#6166ff"}, {"name": "Cracking", "total": "26", "flag": "25", "points": "765", "color": "#ff4141"}, {"name": "Cryptanalysis", "total": "34", "flag": "19", "points": "310", "color": "#b06cfb"}, {"name": "Forensic", "total": "18", "flag": "12", "points": "385", "color": "#35de59"}, {"name": "Progamming", "total": "8", "flag": "8", "points": "175", "color": "#6db8e4"}, {"name": "Realist", "total": "23", "flag": "19", "points": "945", "color": "#ff5887"}, {"name": "Network", "total": "17", "flag": "15", "points": "305", "color": "#e1e0ff"}, {"name": "Steganography", "total": "13", "flag": "12", "points": "210", "color": "#a441ff"}, {"name": "Web-Client", "total": "18", "flag": "16", "points": "490", "color": "#ff84f0"}, {"name": "Web-Server", "total": "51", "flag": "49", "points": "1525", "color": "#35a2ff"}], "challenges": "218", "rank": "37", "avatar": "https://www.root-me.org/local/cache-vignettes/L64xH64/auton7416-97761.jpg"}], "total_points": "11390", "total_challenge": "275"}
34 changes: 27 additions & 7 deletions updater/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import requests
import sys

with open('users.json', 'r') as data_file:
with open('../site/users.json', 'r') as data_file:
data = json.load(data_file)

def wrong_arg():
Expand All @@ -14,6 +14,12 @@ def wrong_arg():
def update_users(user):
print("[+] Starting update profil")
r = requests.get('https://www.root-me.org/'+ user['username'] + '?inc=score')

regex = r'<h1 itemprop="givenName">.*<span .*?>(.*)</span>'
matches = re.search(regex, r.text)
if matches:
user['username_r'] = "{group}".format(group = matches.group(1))

regex = r'<span.*?>\n(.*)<span.*?>/(.*)</span>'
matches = re.search(regex, r.text)
if matches:
Expand Down Expand Up @@ -42,16 +48,29 @@ def update_users(user):
avatar = "{group}".format(group = matches.group(1))
user['avatar'] = "https://www.root-me.org/" + avatar

print("[+]", user['username'], user['realn'], user['avatar'], user['rank'], user['points'] ,user['challenges'], user['status'])
print("[+] Infos user:")
print("\t Url name", user['username'], "\n\t Username", user['username_r'], "\n\t Realn", user['realn'], "\n\t Avatar", user['avatar'], "\n\t Rank", user['rank'], "\n\t Points", user['points'], "\n\t Challenges succed",user['challenges'], "\n\t Status", user['status'])

with open('users.json', 'w') as data_file:
# Get all data from challenge
regex = r'<span.*?>\n([0-9]*)&nbsp;Points&nbsp;([0-9]*)/([0-9]*)'
matches = re.finditer(regex, r.text)
for iter_chall, match in enumerate(matches):
user['details'][iter_chall]["points"] = "{group}".format(group = match.group(1))
user['details'][iter_chall]["flag"] = "{group}".format(group = match.group(2))
user['details'][iter_chall]["total"] = "{group}".format(group = match.group(3))

for detail in user['details']:
print('\t',detail['name'], detail['points'], detail['flag'], detail['total'])

with open('../site/users.json', 'w') as data_file:
json.dump(data, data_file)

print("[+] End update profil")

def update():
print("[+] Starting Update generic information")

# get generic data
r = requests.get('https://www.root-me.org/fr/Communaute/Classement/')
regex = r'<a href=".*?>([0-9]+)</a>'
matches = re.search(regex, r.text)
Expand All @@ -64,23 +83,24 @@ def update():
if matches:
data['total_challenge'] = "{group}".format(group = matches.group(2))

print("\t Total oints", data['total_points'], "\n\t Total challenge", data['total_challenge'])
print("[+] End of update generic information")

for user in data['users']:
update_users(user)

def add_user(username, realn):
print("[+] Starting to add user", username)

data['users'].append({"username": username , "realn": realn, "avatar": "https://www.root-me.org/local/cache-vignettes/L48xH48/auton0-5220c.png", "rank": "0", "points": "0", "challenges": "0", "status": "newbie"})
with open('users.json', 'w') as data_file:
data['users'].append({"username": username, "username_r": "", "realn": realn, "avatar": "https://www.root-me.org/local/cache-vignettes/L48xH48/auton0-5220c.png", "rank": 0, "points": 0, "challenges": 0, "status": "newbie", "details": [{"color": "#dbff6b", "total": "0", "points": "0", "flag": "0", "name": "App-Script"}, {"color": "#6166ff", "total": "0", "points": "0", "flag": "0", "name": "App-System"}, {"color": "#ff4141", "total": "0", "points": "0", "flag": "0", "name": "Cracking"}, {"color": "#b06cfb", "total": "0", "points": "0", "flag": "0", "name": "Cryptanalysis"}, {"color": "#35de59", "total": "0", "points": "0", "flag": "0", "name": "Forensic"}, {"color": "#6db8e4", "total": "0", "points": "0", "flag": "0", "name": "Progamming"}, {"color": "#ff5887", "total": "0", "points": "0", "flag": "0", "name": "Realist"}, {"color": "#e1e0ff", "total": "0", "points": "0", "flag": "0", "name": "Network"}, {"color": "#a441ff", "total": "0", "points": "0", "flag": "0", "name": "Steganography"}, {"color": "#ff84f0", "total": "0", "points": "0", "flag": "0", "name": "Web-Client"}, {"color": "#35a2ff", "total": "0", "points": "0", "flag": "0", "name": "Web-Server"}]})
with open('../site/users.json', 'w') as data_file:
json.dump(data, data_file)

print("[+] End of add")
# then update lasted
update_users(data['users'][-1])


### STARTING POINT####
# ## STARTING POINT####
if len(sys.argv) < 2:
wrong_arg()
else:
Expand Down

0 comments on commit a894881

Please sign in to comment.