r4sas / PBinCLI

PrivateBin CLI on python 3
MIT License
65 stars 25 forks source link

Cant get Onion sites to work or Tor in general? #40

Closed ghost closed 1 year ago

ghost commented 1 year ago

So I can't get PBinCLI to work with Tor.

I have tried these types of variations in the terminal:

$ pbincli send -x socks5://127.0.0.1:9050 -q -f pub.asc -E 1day -B -s http://thetorsiteishere.onion

$ torsocks -i pbincli send -x -q -f pub.asc -E 1day -B -s http://thetorsiteishere.onion

cd'd in correct folder that had .asc file : $ pbincli send -x socks5://127.0.0.1:9050 -t "test" -f pub.asc -E 1day -B -s http://thetorsiteishere.onion

$ torsocks -i pbincli send -t "test" -f pub.asc -E 1day -B -s http://thetorsiteishere.onion

Also noted I have onioncircuits package installed and showed "succeeded" so it did connect to the onion site and also did verify it was not down in Tor browser and via torsocks curl -I.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/user/.local/bin/pbincli", line 8, in sys.exit(main()) File "/home/user/.local/lib/python3.9/site-packages/pbincli/cli.py", line 161, in main args.func(args, api_client, settings=CONFIG) File "/home/user/.local/lib/python3.9/site-packages/pbincli/actions.py", line 38, in send version = api_client.getVersion() File "/home/user/.local/lib/python3.9/site-packages/pbincli/api.py", line 72, in getVersion jsonldSchema = self.session.get( File "/home/user/.local/lib/python3.9/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

r4sas commented 1 year ago

Hello. Thank you for reporting. Please test latest commit.

ghost commented 1 year ago

@r4sas So removed line 7 in the api.py and added the lines you added and made sure it was exactly the same.

Did same things as above: pbincli send -x socks5://127.0.0.1:9050 -t "test" -f pub.asc -E 1day -B --server http://theonionsite.onion

torsocks -i pbincli send -t "test" -f pub.asc -E 1day -B -s http://theonionsite.onion

and this is the errors for both I got now:

Traceback (most recent call last):
  File "/home/user/.local/bin/pbincli", line 5, in <module>
    from pbincli.cli import main
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/cli.py", line 5, in <module>
    import pbincli.actions
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/actions.py", line 4, in <module>
    from pbincli.api import Shortener
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/api.py", line 7
    scheme = settings['proxy'].split('://')[0]
TabError: inconsistent use of tabs and spaces in indentation
Traceback (most recent call last):
  File "/home/user/.local/bin/pbincli", line 5, in <module>
    from pbincli.cli import main
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/cli.py", line 5, in <module>
    import pbincli.actions
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/actions.py", line 4, in <module>
    from pbincli.api import Shortener
  File "/home/user/.local/lib/python3.9/site-packages/pbincli/api.py", line 7
    scheme = settings['proxy'].split('://')[0]
TabError: inconsistent use of tabs and spaces in indentation
ghost commented 1 year ago

@r4sas The problem seems to be that I couldn't send without having a config file set which I think I deleted and didn't have set when trying your fix the second time I think? Either way I got it to work now it seems.

server=https://bin.disroot.org/
proxy=socks5://127.0.0.1:9050
expire=1day
burn=true
format=plaintext
mirrors=http://fgb4city54qtch7pdulgryete6hora4dmsrbuygoczrcdtlgpudaftid.onion/

and

server=http://fgb4city54qtch7pdulgryete6hora4dmsrbuygoczrcdtlgpudaftid.onion/
#proxy=socks5://127.0.0.1:9050
expire=1day
burn=true
format=plaintext
#mirrors=http://fgb4city54qtch7pdulgryete6hora4dmsrbuygoczrcdtlgpudaftid.onion/

Worked with proxy set in config and with torsocks -i (isolation) without proxy set and #comited out and updated by: source ~/.config/pbincli/pbincli.conf. Also with no mirrors and just the onion address. torsocks seems to fail if proxy is set in the config I have noticed also. Only reason of using torsocks is the isolation flag.

This may be possible to set in the proxy= for isolation but have tired it yet.

Secondly I'm not sure why it would require having a config set if you are manually setting the flags when issuing the commands or it doesn't?

Also these this should be noted that:

Lastly Is it possible to set multiply servers to upload/paste to? My understanding is you can only use mirrors like if a site has multiply instances (clear/Tor/I2P)?

Also is there an option to set a directory that you want to get the paste to? Does it default the current folder or always go to ~/home? Maybe add an option for the config or a flag option to set dir to download paste to.

Great python tool you got here 👍

r4sas commented 1 year ago

Use socks5h scheme.

r4sas commented 1 year ago

@r4sas So removed line 7 in the api.py and added the [lines]

...
TabError: inconsistent use of tabs and spaces in indentation

You incorrectly applied diff. Installation from git is easiest way:

pip install git+https://github.com/r4sas/PBinCLI.git
r4sas commented 1 year ago

@r4sas The problem seems to be that I couldn't send without having a config file set which I think I deleted and didn't have set when trying your fix the second time I think? Either way I got it to work now it seems.

Secondly I'm not sure why it would require having a config set if you are manually setting the flags when issuing the commands or it doesn't?

Config file is not required. You can use flags to set everything:

pbincli send -x socks5h://127.0.0.1:9050 -s http://fgb4city54qtch7pdulgryete6hora4dmsrbuygoczrcdtlgpudaftid.onion/ -t "test" -f pub.asc -E 1day -B

Worked with proxy set in config and with torsocks -i (isolation) without proxy set and #comited out and updated by: source ~/.config/pbincli/pbincli.conf. Also with no mirrors and just the onion address. torsocks seems to fail if proxy is set in the config I have noticed also. Only reason of using torsocks is the isolation flag.

This may be possible to set in the proxy= for isolation but have tired it yet.

Also these this should be noted that:

  • # 1. The original onion privatebin I initially tried with doesn't have any clearnet mirror address only a Onion address unlike the ones that did work. So idk if instances that only have onion (no clearnet) address or certain configuration of instaces block this from working?
  • **# 3. If config file has to be present for it to work add flag -i or --ignore-conf` to ignore config file.
  • # 3. Add a flag that generates the config file and maybe with options to it.

You can drop options in config which is not needed, they are empty by default. The --ignore-conf option would be a rather strange solution, it's easier to just delete the config, or set the priority values ​​of the options through the execution line.

Lastly Is it possible to set multiply servers to upload/paste to? My understanding is you can only use mirrors like if a site has multiply instances (clear/Tor/I2P)?

No. mirrors only prints URL for sites with few addresses (like paste.i2pd.xyz, which has mirrors in different networks).

Also is there an option to set a directory that you want to get the paste to? Does it default the current folder or always go to ~/home? Maybe add an option for the config or a flag option to set dir to download paste to.

Good idea, ~maybe~ I'll add option to set the path where we must save decoded paste and files. Currently everything saved in current folder, where tool has been called.

Great python tool you got here 👍

Thank you ;)

ghost commented 1 year ago

@r4sas

Use socks5h scheme.

Isn't socks5h:// for remote DNS compaired to socks5://. Either way you seemed to fix the issue it seems with git commit 08dbceebc63ecb48f248ff1587ca3b80c6b249f7 and proxy=socks5://127.0.0.1:9050set in config seems to work for me though? (even though I mainly use the stream isolation with torsocks -i pbincli if using Tor)

pip install git+https://github.com/r4sas/PBinCLI.git

Thanks I wasn't aware of this method. Does that mean python3 is not required as i just installed with pip3? (asking 4 a friend)

git commit a7d62df9663a3d5a13dfb7c4914b03f877142e83 Awesome tried it --output and it worked nicely

r4sas commented 1 year ago

Isn't socks5h:// for remote DNS compaired to socks5://. Either way you seemed to fix the issue it seems with git commit 08dbcee and proxy=socks5://127.0.0.1:9050set in config seems to work for me though? (even though I mainly use the stream isolation with torsocks -i pbincli if using Tor)

Yes, socks5h tells to use remote DNS (on SOCKS proxy side) resolve. This is preferred because .onion domains can be resolved only by tor, not by standard DNS server, so sosck5h can prevent DNS leak when trying to access to onion domain.

Thanks I wasn't aware of this method. Does that mean python3 is not required as i just installed with pip3? (asking 4 a friend)

Depends on your system. If you have python3/pip3 used by default, then you can use simply pip.

  • Please let me know about this

Response here