[ / / / / / / / / / / / / / ] [ dir / random / cuteboys / cyber / hentai / htg / k / mde / s / wx ]

/g/ - Technology

Make /g/ Great Again
Name
Email
Subject
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
Archive
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Voice recorder Show voice recorder

(the Stop button will be clickable 5 seconds after you press Record)
Options
dicesidesmodifier

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 16 MB.
Max image dimensions are 15000 x 15000.
You may upload 5 per post.


File: 2b12d4e0ac98275⋯.png (95.04 KB, 217x255, 217:255, computer-out-window.png)

 No.8169

PYTHON!

print(colored(' Tell me an IP range [like 1.1.1.0 1.1.1.255', 'blue'))

ipRange = input()

print(colored(' Now I need an IP dir:', 'blue'))

ipDir = input()

print(colored(' Nice! Now wait for the scan to finish!', 'blue'))

time.sleep (3)

os.system("ipscan -f:range' +ipRange '-o' +ipDir'.txt")

How to I make this shit work? ipDir and ipRange simply won't get set by what the user inputs.

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8170

File: 46e482c399b24ae⋯.png (111.47 KB, 528x413, 528:413, 009cd2ca0b0f43e2f6c6755c1d….png)

Your code is shit and you're a faggot. Here's how you should be doing it:

ipRange = raw_input("Enter an IP range (like 1.1.1.0 1.1.1.255): ")
ipDir = raw_input("Enter IP dir: ")
print('Now wait for the scan to finish!')
os.system("ipscan -f:range " + ipRange + "-o " + ipDir + ".txt")

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8171

>>8169

First of all you should use raw_input() instead of input(). Using input() directly will evaluate the user-entered expression which is not what you want.

Secondly, you shouldn't use retarded colours in your output. Get rid of those.

Thirdly, you need to be consistent in your use of quotes. If you start a string with a single quote, you need to end with a single quote, and the same goes for double quotes.

Fourthly, you shouldn't include unnecessary sleep() calls unless absolutely necessary, because it slows down your script.

Fifth, you should be mindful of concatenation and spacing in your concatenated strings. Otherwise, things will not work.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8172

>>8170

I figured it out on my own.

print(colored(' Tell me an IP range [like 1.1.1.0 1.1.1.255', 'blue'))

ipRange = input()

print(colored(' Now I need an IP dir:', 'blue'))

ipDir = input()

print(colored(' Nice! Now wait for the scan to finish!', 'blue'))

time.sleep (3)

scan = "ipscan -f:range " + ipRange + " -o " + ipDir + ".lst"

os.system(scan)

And fuck you.

>>8171

>Using input() directly will evaluate the user-entered expression which is not what you want

Why not?

>Secondly, you shouldn't use retarded colours in your output. Get rid of those.

Its my script and if I want it to prompt questions using retarded colors then it will.

>Thirdly, you need to be consistent in your use of quotes. If you start a string with a single quote, you need to end with a single quote, and the same goes for double quotes.

True. Thanks.

>you shouldn't include unnecessary sleep() calls unless absolutely necessary, because it slows down your script.

That's the point, retard. It sleeps for 3 seconds so the user will have the time to read the explanation before another window pops up in front of the terminal.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8173

>>8172

>Why not?

Because it doesn't fucking work, that's why. At least that is the case on my machine. It shows a syntax error. Apparently it doesn't work for python over 2.7 but if your python is older it would work fine.

>Hurr hurr hurr my way is always better

suit yourself lol

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8174

>>8173

It works on my machine with python 3.5.2. Where is your god now huh?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8175

>>8174

>>8173

under 2.7*

mebbe a little brain damage

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8176

>>8175

Ah, okay then.

By the way, how can I make more colored text get printed on the same line as this one?

print(colored(' Text and more text: ', 'blue') + var) >>>more text here<<<

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8177

>>8176

print(colored('Green text ' + var1, 'green') + colored(' Blue text ' + var2, 'blue'))

Try it and see if it works. I'm pretty sure it will but I don't have colored text installed because I don't use it.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8178

>>8177

Yay it worked.

How can I be more like you and know stuff?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8179

>>8178

Btw can I make the input question colored too?

print(colored(' Now I need an IP dir:', 'blue'))

ipDir = input()

The text always appears white (as my regular terminal's text color). I wanted the text typed in to appear blue too.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8180

>>8179

sorry I have no idea how to go about doing that using colored().

But as a really shitty hack you could do:

blue = '\033[34m'
normal = '\033[0m'
print(blue + ' Now I need an IP dir:')
ipDir = input()
print(normal + 'This text is now the default color')

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8181

File: 8895f75a394de51⋯.jpg (8.14 KB, 250x233, 250:233, 1404686890866.jpg)

>>8180

Its okay. If it works as is than its sufficient. I was just trying to make eye candy.

Do you know how to use grep?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8182

>>8181

>Do you know how to use grep?

I'm quite proficient with it. What's your question?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8183

>>8182

Lets say I've got a file with a list of IPs and ports in it, like:

192.0.0.1:80

192.122.1.1:22

... and so on.

How can I make grep capture each line of this file, set the IP to a variable and then the port to another, and then pass it to nmap like "grep ipfile [arguments] > nmap $ip -p $port"?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8184

>>8183

You can't use grep for that. You can use a shell loop with `cut` as follows:


for line in $(cat file.txt); do
IP=$(echo $line | cut -d: -f1)
PORT=$(echo $line | cut -d: -f2)
nmap "$IP" -p "$PORT"
done

Note that this only works if each line of your file contains no space characters. If it does, you need to use another method (which is similar but different).

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8185

>>8184

Can I do that with python instead?

I remember reading something where the guy would first grep the content and use cut to delimit stuff aground the grepped word.

I want to get the IP and port, and then store it under a variable within the python code so I can use it later with os.system commands. Would it be possible?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8186

>>8185

Definitely possible, but I haven't coded python in 5 years so I wouldn't be able to tell you, sorry. Just search "text processing in python" and you'll be able to find out.

But with what you look like you're doing, it might be easier and faster to just write it in bash (you can even color your text).

Also, what are you trying to do? Are you trying to scan the internet for something? If so there's a more efficient way. I once scanned the entire internet to search for obscure imageboards, and I used zmap which can scan thousands of IPs per second (albeit less reliably than nmap).

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8187

>>8186

I tried bash, but I'd had to learn how to do thing that I already know in python, so I gave up.

>I once scanned the entire internet to search for obscure imageboards, and I used zmap

That's is pretty similar to what I'm doing. Can zmap scan an IP range, filter the IPs with X open ports and then scan their services so they can get exported to a text file?

I've never used it.

After going through cut I'd use nmap to scan for the services. I'd produce one file per host scanned with the target port open and if they had the service I'm looking for then I'd merge it with other hosts running the same service on X port within one giant list of IPs.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8188

>>8187

I mean't how to do things"

Sorry.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8189

>>8187

Fuck I'm wiring like I'm drunk.

I've been up for 21 hours now.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8190

File: 93564f0485fd041⋯.png (5.62 KB, 494x85, 494:85, absolute_state_of_tech.png)

>>8187

That's exactly what zmap can do. However, I haven't used that in some time, and you'd have to study the manual pages to figure out how to use it. But I know for a fact that you can do that.

If your IP range isn't very large, though, it'd be better just to use nmap with an IP range specifier. For example to scan everyone on my home wifi:

nmap -T4 192.168.1.1/24

Zmap requires a shit ton of fiddling to get things right. Just don't use it unless you absolutely have to. It slows down your internet because it scans so fast.

>>8189

>wiring

lol

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8191

>>8190

I'm scanning 65 thousands IP at a time, like 66.125.0.0/16.

>Zmap requires a shit ton of fiddling to get things right

No worries, I'm not that lazy.

Can I pass it through my python script so It looks fancy?

My router is pretty crappy, so I can't use more than 50 threads of so otherwise I'm basically DoSing my own router. Threads start to drop, I don't get any ping responses, plus there is 100% packet drop until I let go of the scan.

It has nothing to do with my card neither my cpu. I've tested it with another router and I was able to have 200 threads open.

>wiring

>lol

I meant "writing", but then I realized I'm typing on a keyboard, not handwriting something. Thats how sleep drunk I am.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8192

File: 1f4ec0058905d2d⋯.png (162.84 KB, 459x414, 51:46, 1f4ec0058905d2d0f5053bab52….png)

>>8191

>/16

Then you should probably use zmap because nmap will be way too slow.

>python script so it looks fancy?

If I recall correctly, zmap already has coloured output.

>My router is pretty crappy

Then you need to use the rate-limiting options of zmap limit to however many packets per second doesn't crash it. If you do 50 packets per second, it shouldn't take too long to scan a /16 range. Maybe like a few days.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8194

File: d0c83da2da18174⋯.png (32.05 KB, 315x372, 105:124, ClipboardImage.png)

>>8191

With 50 threads It takes me about 15 minutes to scan 65025 ips with ipscan, which is pretty good.

Through command line I can make it export automatically all the ips and ports to a file, then I just need to scan all of those IP addresses and tell nmap to look for services and log the output to a file, and then make only the IPs with certain services to get passed to the final file.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8195

>>8194

>ipscan

yeah, but ipscan can only tell if the IP address exists. The nmap part takes much longer. I believe that zmap can do both at once.

>50 threads

50 threads should equal around 100 packets per second with zmap. It would take approximately 10 minutes. (The previous estimation of a few days was off quite a bit because I didn't do any calculations).

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8196

>>8195

>I believe that zmap can do both at once

Although I must note that zmap only scans for open ports. If you want more detailed information such as exactly what services are running on that port, you still need to use nmap, but you can narrow the nmap scan down enough that it would take significantly faster.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8197

File: 80f33c3506e703b⋯.png (9.44 KB, 147x411, 49:137, ClipboardImage.png)

>>8195

Actually ipscan can be set to display and export only ips with the defined ports to be shown.

>>8196

So zmap will only tell me what IP addresses from that range have their ports open? Thats pretty much what ipscan does. LOL

So if I've got a list of files with ip:port, one ip for each new line, how can I tell nmap to scan each of them individually? Will cut do that?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8198

>>8197

>ports open to be shown

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8199

File: 9eb47dda4668fc9⋯.png (22.22 KB, 358x414, 179:207, ClipboardImage.png)

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8200

>>8197

Whatever just use ipscan because you're familiar with it. As I said, zmap takes fiddling around and it is basically the same thing.

>I've got a list of files with ip:port

This bash script >>8184 is what you need.

You may need to add extra nmap options such as -A if you want to detect specific service versions running behind that port.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8201

>>8200

But I want the nmap output to get filtered and then only the IP addresses of which the port is running the target service is written to a new and final file.

The final file should look like this, and they should have only IPs with the open port and running the service I'm looking for:

ip:port service

ip2:port service

[...]

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8202

>>8201

Basically what you need to do is to check the return status of nmap. If failure, don't write the line to the file. If it succeeded, use grep to search for the particular line which contains the output you're looking for, and append that line to your output file.

I have to go to bed now so I can't answer any more questions.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

 No.8204

>>8202

Thanks for the help.

I'll find out on my own. Its not like you're my slave.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



[Return][Go to top][Catalog][Nerve Center][Random][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / random / cuteboys / cyber / hentai / htg / k / mde / s / wx ]