[Tutor] need help with socket / fuzzer not sure the while loop condition is wrong

2016-07-21 Thread la Y
need help with socket / fuzzer not sure the while loop condition is wrong - its 
superpose to fuzz testing programs over till program crashes but seems to have 
some errors.



import os
import sys
import datetime
import socket


def fuzzer():
#fuzzer
#user attack coordinates and junk
currentEta = datetime.datetime.now()
targetIP = raw_input("hello what is the target IP destinaition address: ")
socketPort = int(raw_input("what port number : "))

while ( socketPort < 4 ) and (socketPort <= 65535):
socketPort = int(socketPort)

junkData = raw_input("paste your junk for fuzzing [pattern create would be 
perfered]")



# Symbolic name meaning all available interface
#  Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((targetIP , socketPort ))
s.listen(1)
conn, addr = s.accept()
print ("Connected by",+ addr)

counter = 0
print(currentEta)
print("Current Phase 1 initated")
print(targetIP)
print(socketPort)
print(junkData)

print(":sending:=> fuzzie fuzzie")

while conn.open(counter,junkData,data):
counter =+ 1
junkData = junkData + 1
print(counter)
print(junkData)
data = conn.recv(1024)
if not data: break
conn.sendall(junkData)
conn.open()


#option selection
print("Please Select an option")
options = input("1: Fuzzer n/ 2: Port Scanner ")

if options == 1:
#run
fuzzer()
elif options == 0:
exit()

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need help with socket / fuzzer not sure the while loop condition is wrong

2016-07-21 Thread Alan Gauld via Tutor
On 21/07/16 12:50, la Y wrote:
> need help with socket / fuzzer 


UI've no idea what fuzzer means but...

> not sure the while loop condition is wrong

> def fuzzer():
> #fuzzer
> #user attack coordinates and junk
> currentEta = datetime.datetime.now()
> targetIP = raw_input("hello what is the target IP destinaition address: ")
> socketPort = int(raw_input("what port number : "))
> 
> while ( socketPort < 4 ) and (socketPort <= 65535):
> socketPort = int(socketPort)

This makes no sense at all.

The socketPort is already an int because you make it so
on the raw_input line.

If it is <4 it will also be less than 65535 so the "and"
test is superfluous.

And if it is <4 the while loop will run forever because
you never change the value of socketPort.

if
x = int(n)
then
int(x) == x

is always true

I've no idea what the loop is intended to do so I can't
comment on whether you need to just delete it or whether
you need to modify it somehow.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Re: Help me out please

2016-07-21 Thread Danny Yoo
Apologies: I don't have time at the moment to answer.  Forwarding to the
mailing list!
-- Forwarded message --
From: "Marc Sànchez Quibus" 
Date: Jul 21, 2016 12:08 AM
Subject: Re: [Tutor] Help me out please
To: "Danny Yoo" 
Cc:

Thanks for your fast reply. I'm gonna explain a little bit more about my
problem to be more understood.
Well, I have two scripts. One in Python and the other one in html.
Inside the html's script you can find out these lines:


initLatencymon(
'#latencyMON',
{},
{ measurements:[*3679333, 3793762*]}
);


I need to change these *bold *variables from the Python's script. Inside
this one, there are just some prints, system's functions and so on. I would
like to create, at least, some variable in python to select the value of
the varible in HTML. Better if it could be chosen as input( ). Either some
variable or a function. If you need more infromation let me know.
Thanks in advance.
Marc

2016-07-21 7:38 GMT+02:00 Danny Yoo :

> On Tue, Jul 19, 2016 at 4:31 AM, Marc Sànchez Quibus
>  wrote:
> > Hi,
> > First of all I'm gonan introduce myself. My name is Marc and I'm a
> student
> > and also a python's programmer begginer. I've been studying/learning
> python
> > and now I need some help to finish my project.
> > I have two scripts, one of them in python (the main script) and the other
> > one written in html. Well, is just a brief javascript (an app) that I
> took
> > by Github. I need to change a variable inside this html script. I was
> > wondering wether I could change this variable from my python script or
> not.
> > Is there some way to do it?
>
> Hi Marc,
>
> Yes.  You might want to read something like this to get some
> background.  Phil Greenspun's Guide to Web Publishing:
>
> http://philip.greenspun.com/panda/
>
> Specifically, the chapter "Sites that are really progarms".
>
> http://philip.greenspun.com/panda/server-programming
>
> You mentioned that you have two scripts, one in Python and the other in
> HTML.
>
> A web site can be seen as this: something that (1) takes in a web
> request sent by a browser, and (2) spits out a web response.
>
> A static web site takes in a web request, looks for an appropriate
> file, and prints that file back as a web response.  But that's not the
> only way we can build web responses.  A programmatic web site can take
> that request and *generate* a web page on the fly.  A web site can
> actually be a program: not just a plain text file.
>
>
> There are a lot of resources to teach how to write programs that serve
> web sites.  Another by the same author is
> http://philip.greenspun.com/seia/, which goes into a lot more detail.
>



-- 
*Marc Sànchez Quibus*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: Re: Help me out please

2016-07-21 Thread Alan Gauld via Tutor
On 21/07/16 21:17, Danny Yoo wrote:

> Well, I have two scripts. One in Python and the other one in html.
> Inside the html's script you can find out these lines:
> 
> 
> initLatencymon(
> '#latencyMON',
> {},
> { measurements:[*3679333, 3793762*]}
> );
> 
> 
> I need to change these *bold *variables from the Python's script. 

That's technically not too difficult at a file level, especially if
you use an html parser like Beautiful Soup. But whether that's the
best way depends on how the files are used.

How is the html file accessed? Is it independent of the python script?
In other words doers the python script run as a batch job that only
updates the values occasionally? Or regularly? (How often?) or is it on
demand - some other trigger starts the Python script?
Or does the Python script somehow start from an action by the html script?

Its all very vague just saying you have two files.
WE need to understand the intended interaction between them.

If it is just a daily or hourly update then the html parser
route is probably adequate. If its driven by an external
trigger then it might be ok but might not.

And if its driven by the html script itself then we almost
certainly need a redesign of how you are doing things.

So can you start by explaining the use case scenario
for these interactions. How do the file get executed?
What triggers them?

How do they interact (if, indeed, they do)?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python programmin problem

2016-07-21 Thread Alan Gauld via Tutor

Forwarding to list. Please use reply-all when responding to tutor messages.

As Danny suggested this is quite a complex problem. I wasn't sure whether
it was just the programming or the bigger algorithm issue you were stuck on.

For now I'd stick with the code you have and think about how to use that
to build up a list of runs and then find the longest. Hint: Start
testing at
progressive items in your initial sequence.

Hopefully somebody else can pick this up as I have to go away for a fewys...

Alan G.

On 22/07/16 06:02, monik...@netzero.net wrote:
> Hi:
> Thank you so much for your suggestion. I was able to turn it into the code 
> but Im stuck on catching the [1,2,3,5,6] case case. Could you please be so 
> kind and give me a hint? I apologize for not having much experience on this 
> but things like that were never taught in any of the classes I took and I 
> have nowhere else to ask.
> Thank you so much.
> Monika
>
>
> Here is my code:
>
> run = []
> for i in range(len(items)):
> if i == 0:
> run += [items[i]]
> continue
> else:
> if items[i - 1] < items[i]:
> run +=[ items[i]]
> elif items[i - 1] > items[i]:
> del run[-1]
> run += [items[i]]
> print run
>
> -- Original Message --
> From: Alan Gauld via Tutor 
> To: "monik...@netzero.net" 
> Cc: tutor@python.org
> Subject: Re: [Tutor] python programmin problem
> Date: Thu, 21 Jul 2016 01:26:59 +0100
>
> On 21/07/16 00:14, monik...@netzero.net wrote:
>> IM not able to figure out algorithm to find the runs.
>> Here is the code I have:
> OK, Forget about code for now. just focus on what is being asked.
>
>>> The first question to ask is can you do it without a computer?
>>> In other words given
>>>
>>> input [1,7,2,3,5,4,6]
>>>
>>> Can you first of all produce a list of all valid runs?
> Lets try it manually. Start with 1
>
> run = []
> 1 > run[-1] so add it to the run -> [1]
> 1 is followed by 7 which >run[-1] so add it to the run -> [1,7]
> 7 is followed by 2 which  [1]
> 2 is now greater than run[-1] so add it to the run -> [1,2]
> 2 is followed by 3 which is > run[-1] so add it to the run -> [1,2,3]
> 3 is followed by 5 which is > run[-1] so add it to the run -> [1,2,3,5]
> 5 is followed by 4 which is  4 is now >run[-1] so add it to the run -> [1,2,3,4]
> 4 is followed by 6 which is > run[-1] so add it to the run -> [1,2,3,4,6]
> 6 is not followed by anything, run complete.
>
> Can you see an algorithm there that you can code?
> Its not quite complete because it never catches the [1,2,3,5,6] case
> but its a start. And there are probably more efficient algorithms too,
> but we are interested in easy to code here not speed.
>


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor