Спамер на питоне код

Spambot: How to create an advanced Spam Bot with Python

Want to create a spam bot? If so, read this article now and find out how to create your own spam bot with python that works for every chat.

Setup

Before we start coding a spam bot, we first need to install python with pip. If you haven’t done that already you can follow the instructions here.

After that part is done, we need to install the python keyboard package. To do so, open the terminal on Linux and MacOS or the command prompt on Windows. In the window that now appears, type in pip install keyboard.

Now that everything is set up, we need to create a python file by simply creating a new file with the extension .py, e. g. spambot.py. To begin with the coding part, just open up that file in a code editor of your choice. I am using Visual Studio Code for this tutorial.

Coding the spam bot

You can find the full source code here.

The first thing we need to do is import some modules. To do so, write the following lines into your python file.

import keyboard import sys import time

We use the keyboard module for automatically typing into text fields. The sys module we use for command line arguments, and the time module is used for setting the spam delay.

Next, we define some variables and functions to handle the hotkey that starts and stops the bot.

# hotkey state pressed = False # define hotkey pressed method def setPressed(): global pressed pressed = not pressed # define hotkey keyboard.add_hotkey("alt + a", setPressed) # you can change this to any other key combination

After that, we include the last part. It is responsible for checking the provided command line arguments and spamming when the hotkey is pressed.

currentTime = 0.0 if len(sys.argv) < 2: print("Usage: py spambot.py [ -d | -t ]") # Provide the user with usage information sys.exit(1) delay = 0.25 exitTime = None if "-d" in sys.argv: try: if float(sys.argv[sys.argv.index("-d") + 1]) >= 0.01: delay = float(sys.argv[sys.argv.index("-d") + 1]) else: print("Delay can't be lower than 0.01") sys.exit(1) except: print("Only float values are allowed for delay attribute!") # Exit if the user didn't provide a valid number sys.exit(1) if "-t" in sys.argv: try: exitTime = float(sys.argv[sys.argv.index("-t") + 1]) except: print("Only float values are allowed for exit time attribute!") # Exit if the user didn't provide a valid number sys.exit(1) msg = str(sys.argv[1]) + "\n" if exitTime is not None: exitTime -= delay while True: while pressed: # When the user has pressed the hotkey if exitTime is not None: # if we've got an exit time, exit when it's reached if currentTime 

Done! That’s how you code an advanced spam bot in Python.

Usage

To now finally use the spam bot, you have to again open your terminal and then change the directory to the path where you created your file. You can do so by typing cd . Then type:

Replace spambot.py with your own file name and provide the command line arguments. The arguments in the squared brackets ([]) are optional. If you want to spam a message with spaces, put it in quotation marks.

Example

start spam bot

To start/stop spamming, press the hotkey alt + a.

Thanks for reading!

Interesting Reads

Convert Python to Exe

Python to Executable: Easily Convert a Python File to an Executable

Coding on Mobile: Is it Possible to Write Code on Your Phone?

10 Reasons Why Programming is Fun!

Python to Executable ✓ Learn how to easily convert Python script files into executables for Windows and Linux. PyInstaller & auto-py-to-exe ✓ […]

Find out how to set up an SSH server on your Windows computer using OpenSSH! Get Remote Shell Access to your Windows computer. […]

Coding on mobile - Is it really possible? We all know that code is written on computers but does it also work with a regular phone? […]

Here's why programming is fun! Click to read more and find out what keeps programmers motivated and why the hobby is actually fun. […]

How are programming languages made? How was the first programming language created? Can you really program a programming language? […]

Copyright © 2023 CoolplayDev - Oliver Zink

To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.

The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.

The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.

The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.

The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.

Источник

Статья Простой спаммер на Python - забавы лишь ради

Сегодня будем писать простенький скрипт на Питоне, который будет проводить спам атаку в сторону нашей жертвы.
Механизм работы кода прост, он пишет выбранное нами слово и нажимая 'Enter' отправляет его нашей жертве.
Инструкция написана так, чтобы даже ребенок понимал каждый шаг, так что особых знаний тут не надо, кроме умения пользоваться мышкой и клавиатурой.

Сначала создадим папку и там же два блокнота, один с них сохраняем, дав название "script.py", второй называем, как "text.txt".
В первый файл будем писать наш код, в второй файл вставим текст на ваш выбор ( ТОЛЬКО НА ЛАТИНИЦЕ ).

Импортируем модули для автоматизации и заморозки сценария:

import time # Модуль для работы с временем. import pyautogui # Модуль для управления мышью и клавиатурой, точнее главный модуль в нашем программном коде.

Модуль "Time" нужен нам для того, чтобы мы успели активировать поле ввода, прежде чем скрипт начнет спамить.

Теперь создаем первую функцию, роль которой "стрелять" одним сообщением N-ое количество раз:

def SendMessage(): time.sleep(2) # Замораживает скрипт на 2 секунды, чтобы мы успели активировать поле ввода. message = "U ARE UGLY" # Сообщение которое мы хотим отправлять пишем в кавычках. iterations = 1000 # 1000 раз отправляет данное сообщение. for i in range(iterations): pass while iterations > 0: iterations -= 1 pyautogui.typewrite(message.strip()) # Пишет слово/текст написанный в переменной "message" pyautogui.press('enter') # и нажимая Enter, отправляет его нашей "жертве". print("Вся обойма попала в нашу жертву!")

Затем создаем вторую функцию, которая уже отправляет текст вписанный в наш блокнот:

def SendText(): time.sleep(2) with open('text.txt') as f: # Открывает блокнот с названием text.txt (документ с содержанием того, что мы хотим отправлять). lines = f.readlines() for line in lines: pyautogui.typewrite(line.strip()) # В этой функции оно будет писать текст с каждой строки pyautogui.typewrite('enter') # и так же отправлять его "жертве". print("Дело сделано, осталось успокоить нашу жертву ^_^")

Подходим уже к концу, осталось лишь добавить "панель управления":

print('~'*50) print("[1] ===> Стрелять одним сообщением указанным в переменной ") print("[2] ===> Отправлять строки из блокнота ") print('~'*50) option = input("[Выбирай функцию]===> ") if option == "1": SendMessage() elif option == "2": SendText() else: print('Выбирай функция 1 или 2!')

Осталось лишь найти текст песни/стих или что-то там еще на английском языке и вставить его в наш "text.txt".

They say, oh my god, I see the way you shine
Take your hands, my dear, and place them both in mine
You know you stopped me dead while I was passing by
And now I beg to see you dance just one more time
Ooh I see you, see you, see you every time
And, oh my, I, I, I like your style
You, you make me, make me, make me wanna cry
And now I beg to see you dance just one more time
So they say
Dance for me
Dance for me
Dance for me oh oh oh
I've never seen anybody do the things you do before
They say
Move for me
Move for me
Move for me ay ay ay
And when you're done, I'll make you do it all again
I said, oh my god, I see you walking by
Take my hands, my dear, and look me in my eyes
Just like a monkey I've been dancing my whole life
But you just beg to see me dance just one more time
Ooh I see you, see you, see you every time
And, oh my, I, I, I,
I like your style
You, you make me, make me, make me wanna cry
And now I beg to see you dance just one more time
So they say
Dance for me
Dance for me
Dance for me oh oh oh
I've never seen anybody do the things you do before
They say
Move for me
Move for me
Move for me ay ay ay
And when you're done I'll make you do it all again
They say
Dance for me
Dance for me
Dance for me oh oh oh
I've never seen anybody do the things you do before
They say
Move for me
Move for me
Move for me ay ay ay
And when you're done I'll make you do it all again
They say
Dance for me
Dance for me
Dance for me oh oh oh
I've never seen anybody do the things you do before
They say
Move for me
Move for me
Move for me ay ay ay
And when you're done I'll make you do it all again
They say
Dance for me
Dance for me
Dance for me oh oh oh
I've never seen anybody do the things you do before
They say
Move for me
Move for me
Move for me ay ay ay
And when you're done I'll make you do it all again
All again

По неизвестным мне причинам, скрипт НЕ пишет слова или текст на кириллице, только на латинском.
Чтобы остановить работу нашей машины, нажмите на командую строку и выполните комбинацию Ctrl + C, либо просто закройте командую строку.

Какой-то серьезной опасности или важной опции данный скриптик не выполняет, больше предназначен для забавы.
Идею написания такого я взял у одного иностранца которого именно уже не помню, а сам выполняемый файл был написан мной, так что эта статья её первоисточник

Также приложил видео с обзором работы скрипта:

Это моя первая статья и в Python'e я лишь новичок, так что строго не судите.

from termcolor import colored import subprocess import time import pyautogui subprocess.call('', shell=True) def SendMessage(): time.sleep(2) # The message you want to send message = "U ARE UGLY" # How many times do i send a message? iterations = 5 for i in range(iterations): pass while iterations > 0: iterations -= 1 pyautogui.typewrite(message.strip()) pyautogui.press('enter') print('Done, high five') def SendScript(): time.sleep(2) with open('script.txt') as f: lines = f.readlines() for line in lines: pyautogui.typewrite(line.strip()) pyautogui.press('enter') print('It was hard, but we did it, high five.') print(colored('~'*50, 'red')) print(colored('Welcome bro \(O V O)/', 'green')) print(colored("Let's make fun of someone?", 'green')) print(colored('~'*50, 'red')) print(colored("\t[1] ===> Resend the same message (─__─)", 'magenta' )) print(colored("\t[2] ===> Send titles from the script \(v _ v)/", 'magenta')) print(colored('~'*50, 'red')) print('\n') option = input(colored('[Choose an option]==> ', 'cyan')) if option == "1": SendMessage() elif option == "2": SendScript() else: print(colored('Choose a function! ¯\_(-_-)_/¯', 'red'))

Источник

Читайте также:  Python float round precision
Оцените статью