Giter VIP home page Giter VIP logo

htb-api's Introduction

PyHackTheBox

Run Tests codecov Documentation Status PyPI version

PyHackTheBox is an unofficial Python library to interact with the Hack The Box API.

Install

$ pip install pyhackthebox

Demo

from hackthebox import HTBClient
# Create an API connection
client = HTBClient(email="[email protected]", password="S3cr3tP455w0rd!")
# Print the User associated with the client
print(client.user)

Documentation

The documentation is available here.

Current Features

  • Logging into the API (and automatically refreshing access tokens)
  • Challenges, Machines, Fortresses and Endgames
    • Getting details
    • Viewing authors
    • Viewing first bloods
    • Submitting flags
  • Searching Users, Challenges, Machines and Teams
  • Spawning and stopping Challenge instances
  • Retrieving user activity
  • Viewing Hall(s) of Fame (Top 100, VIP, Team and University Leaderboards)

htb-api's People

Contributors

0xdf223 avatar clubby789 avatar dr-gecko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

htb-api's Issues

Submitting reviews

  • Machine reviews/star ratings
  • Challenge like/dislike
  • Prolab testimonial

Add more exception types

  • Invalid ID (user, team etc.)
  • Failure to retrieve all data
  • Invalid flag? Might be worth returning True or False

Submitting flags

Add the ability to submit flags for all content types.

  • Challenges
  • Endgames
  • Fortresses
  • Machines
  • Pro Labs

Avatar URL fix

There is an issue with the API not being able to pull the users avatar, this can be fixed by going to hackthebox/user.py, on line 145 adding self.avatar = f'https://www.hackthebox.com{data["avatar"]}'

Suggestion: Add total ownership to User class

I was working on a small project using this api, and I needed to get the total ownership of my user. However, the User class doesn't seem to have this as a class attribute, and I think it would be a useful addition. I can obviously calculate total ownership given what I have, but it would be a nice QoL change.

Thanks!

(I would try and contribute this myself but I don't know if I have the time to :) )

async support?

Will we see async support in the future, or is this not planned?

Improve the examples

Ideally the examples should demonstrate most of the features - the tests aren't perfect for this purpose.

cant get machines

Getting machines doesnt seem to be working, I think HTB made some changes?

  File "/usr/local/lib/python3.10/site-packages/hackthebox/htb.py", line 313, in get_machines
    data = cast(dict, self.do_request("machine/list"))['info'][:limit]
  File "/usr/local/lib/python3.10/site-packages/hackthebox/htb.py", line 126, in do_request
    raise NotFoundException
hackthebox.errors.NotFoundException

Use mocking to test flag submission

Currently flag submission is not tested. Since I'd like to avoid mass submitting fake flags, I'd like to use mock to perform testing of these endpoints.

Get Hall of Fame

Retrieve the top N:

  • Users (/rankings/users)
  • VIP users (/rankings/users?vip=1)
  • Users per country (/rankings/countries)
  • Teams (/rankings/teams)
  • Universities (/rankings/universities)

Refactor client init

The client authentication process should be refactored to allow for usage like client = HTBClient(), with the user being automatically prompted for details. Failure to provide an OTP should result in a prompt, rather than an exception. Handle the exception with a prompt from __init__?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.