Code Monkey home page Code Monkey logo

Comments (1)

rbricheno avatar rbricheno commented on June 11, 2024

First off, don't worry, the unicode decoding you are seeing is not because you are attempting to decrypt the password wrong. Your first guess of:

password = pkt.PwDecrypt(pkt[2][0])

is correct. Your program is failing for another reason :-)

At line 8 in pyrad_cli.py you have:

srv=Client(server="10.0.0.1", secret="s3cr3t", dict=Dictionary("/usr/share/freeradius/dictionary.rfc2865"))

At line 100 in pyrad_srv.py you have:

srv.hosts["10.0.0.2"] = server.RemoteHost("10.0.0.2", "passied2", "ied2")

That isn't right, the shared secrets must match. You either need to put "s3cr3t" in both places, or "passied2" in both places.

If the shared secrets do not match, and you do not try to decode the password (as in your example zip), the server is not checking the shared secret used to encrypt the password, it is just sending its 'Ok!' response right away. The client will timeout (as you observed). That's because the client cannot verify the replies, because the shared secret used for the response from the server doesn't match what is on the client.

If the shared secrets do not match, and you try and decode the password, then you will receive the unicode error you mentioned, because the shared secret was used to encode the packet on the client side. So trying to decode it with a different shared secret on the server results in garbage.

If the shared secrets do match, then you will receive accept/reject, and the password can be decrypted as normal.

So, how to deal with the garbage when trying to decrypt a password with a bad shared secret? A simple way would be to replace

password = pkt.PwDecrypt(pkt[2][0])

with:

try:
    password = pkt.PwDecrypt(pkt[2][0])
except UnicodeDecodeError:
    print("DEBUG - Bad shared secret")
    raise ServerPacketError("Bad shared secret")

in pyrad_srv.py.

from pyrad.

Related Issues (20)

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.