Compare commits
No commits in common. "5ad6018a889cc4240056ec2236a2cc983a0fda7f" and "c7958dafa1ccaeb6b05138c429d73b45a891b0e6" have entirely different histories.
5ad6018a88
...
c7958dafa1
8 changed files with 61 additions and 202 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
lib
|
|
||||||
bin
|
bin
|
||||||
|
|
38
README.md
38
README.md
|
@ -1,15 +1,13 @@
|
||||||
# BulkBarrage
|
# ReportSpam
|
||||||
|
|
||||||
BulkBarrage is a command-line tool that enables users to report spam emails to
|
ReportSpam is a command-line tool that enables users to report spam emails to
|
||||||
the SignalSpam platform <signal-spam.fr>.
|
the SignalSpam platform. This tool serves as a bridge between individual users
|
||||||
|
and the SignalSpam service, facilitating the process of submitting spam for
|
||||||
This tool serves as a bridge between individual users and the SignalSpam
|
investigation and action.
|
||||||
service, facilitating the process of submitting spam for official investigation
|
|
||||||
and action.
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
BulkBarrage is a community-driven project developed independently from
|
ReportSpam is a community-driven project developed independently from
|
||||||
SignalSpam. It offers a convenient way for users to report spam emails directly
|
SignalSpam. It offers a convenient way for users to report spam emails directly
|
||||||
from any email-piping capable mail client by leveraging the HTML forms on
|
from any email-piping capable mail client by leveraging the HTML forms on
|
||||||
SignalSpam's web platform. The project is currently in beta but is mature
|
SignalSpam's web platform. The project is currently in beta but is mature
|
||||||
|
@ -28,14 +26,14 @@ To build the project from source:
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install BulkBarrage, follow these steps:
|
To install ReportSpam, follow these steps:
|
||||||
|
|
||||||
1. Ensure that CrystalLang is installed on your system.
|
1. Ensure that CrystalLang is installed on your system.
|
||||||
2. Clone the repository:
|
2. Clone the repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/your-repo/bulkbarrage.git
|
git clone https://github.com/your-repo/reportspam.git
|
||||||
cd bulkbarrage
|
cd reportspam
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Use the Makefile to build the project:
|
3. Use the Makefile to build the project:
|
||||||
|
@ -46,36 +44,40 @@ To install BulkBarrage, follow these steps:
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
BulkBarrage can be used in a few simple steps:
|
ReportSpam can be used in a few simple steps:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
Usage: bulkbarrage [options] [command]
|
Usage: reportspam [options] [command]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
configure Initialize the configuration
|
configure Initialize the configuration
|
||||||
report Process and report spam email (default: from STDIN)
|
send Process and report spam email (default: from STDIN)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this help
|
-h, --help Show this help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- **Configure**: Set up your initial configuration for using ReportSpam.
|
||||||
|
- **Report**: Pipe an email into the tool to report it as spam.
|
||||||
|
- **Help**: Display the help message for more information.
|
||||||
|
|
||||||
### Reporting Spam
|
### Reporting Spam
|
||||||
|
|
||||||
To report a spam email, you can use the `report` command:
|
To report a spam email, you can use the `report` command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cat spam_email.eml | bulkbarrage send
|
cat spam_email.eml | reportspam send
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
After installation, run `bulkbarrage configure` to set up your user
|
After installation, run `reportspam configure` to set up your user
|
||||||
configuration, which may include credentials or preferences for interacting
|
configuration, which may include credentials or preferences for interacting
|
||||||
with the SignalSpam platform.
|
with the SignalSpam platform.
|
||||||
|
|
||||||
## Issue Reporting
|
## Issue Reporting
|
||||||
|
|
||||||
Issues can be reported on BulkBarrage's Issue Tracker.
|
Issues can be reported on ReportSpam's Issue Tracker.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
10
shard.lock
10
shard.lock
|
@ -1,10 +0,0 @@
|
||||||
version: 2.0
|
|
||||||
shards:
|
|
||||||
lexbor:
|
|
||||||
git: https://github.com/kostya/lexbor.git
|
|
||||||
version: 3.1.2
|
|
||||||
|
|
||||||
mechanize:
|
|
||||||
git: https://github.com/kanezoh/mechanize.cr.git
|
|
||||||
version: 0.2.0
|
|
||||||
|
|
11
shard.yml
11
shard.yml
|
@ -1,9 +1,8 @@
|
||||||
---
|
name: signalspam-pipe
|
||||||
name: bulkbarrage
|
|
||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
|
|
||||||
targets:
|
targets:
|
||||||
bulkbarrage:
|
signalspam-pipe:
|
||||||
main: src/main.cr
|
main: src/main.cr
|
||||||
|
|
||||||
# authors:
|
# authors:
|
||||||
|
@ -12,11 +11,6 @@ targets:
|
||||||
# description: |
|
# description: |
|
||||||
# Short description of signalspam-pipe
|
# Short description of signalspam-pipe
|
||||||
|
|
||||||
dependencies:
|
|
||||||
mechanize:
|
|
||||||
github: Kanezoh/mechanize.cr
|
|
||||||
version: "~> 0.2.0"
|
|
||||||
|
|
||||||
# dependencies:
|
# dependencies:
|
||||||
# pg:
|
# pg:
|
||||||
# github: will/crystal-pg
|
# github: will/crystal-pg
|
||||||
|
@ -27,4 +21,3 @@ dependencies:
|
||||||
# github: manastech/webmock.cr
|
# github: manastech/webmock.cr
|
||||||
|
|
||||||
# license: MIT
|
# license: MIT
|
||||||
license: LGPL-3.0
|
|
||||||
|
|
|
@ -1,27 +1,17 @@
|
||||||
require "yaml"
|
|
||||||
|
|
||||||
# Classe pour la gestion de la configuration
|
|
||||||
class Authentication
|
|
||||||
include YAML::Serializable
|
|
||||||
|
|
||||||
@[YAML::Field(key: "username")]
|
|
||||||
property username : String
|
|
||||||
|
|
||||||
@[YAML::Field(key: "password")]
|
|
||||||
property password : String
|
|
||||||
|
|
||||||
def initialize(@username, @password)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
include YAML::Serializable
|
include YAML::Serializable
|
||||||
|
|
||||||
|
class Authentication
|
||||||
|
include YAML::Serializable
|
||||||
|
|
||||||
|
@[YAML::Field(key: "username")]
|
||||||
|
property username : String
|
||||||
|
|
||||||
|
@[YAML::Field(key: "password")]
|
||||||
|
property password : String
|
||||||
|
end
|
||||||
|
|
||||||
@[YAML::Field(key: "authentication")]
|
@[YAML::Field(key: "authentication")]
|
||||||
property authentication : Authentication
|
property auth : Authentication
|
||||||
|
|
||||||
def initialize(@authentication)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
93
src/main.cr
93
src/main.cr
|
@ -1,69 +1,32 @@
|
||||||
require "./config"
|
require "yaml"
|
||||||
require "./providers/signal_spam"
|
|
||||||
|
|
||||||
require "http/client"
|
require "http/client"
|
||||||
require "option_parser"
|
require "./config.cr"
|
||||||
require "file_utils"
|
require "./version.cr"
|
||||||
require "mechanize"
|
|
||||||
|
|
||||||
# Nom du script et version
|
|
||||||
SCRIPT_NAME = "BulkBarrage"
|
|
||||||
SCRIPT_VERSION = "0.1.0"
|
|
||||||
|
|
||||||
# Classe pour gérer les interactions avec Signal-Spam
|
|
||||||
class SignalSpamCtl
|
|
||||||
def initialize
|
|
||||||
@option_parser = OptionParser.new do |parser|
|
|
||||||
parser.banner = [
|
|
||||||
"#{SCRIPT_NAME} v#{SCRIPT_VERSION}",
|
|
||||||
"Usage: bulkbarrage [options] [command] [args]"
|
|
||||||
].join("\n")
|
|
||||||
|
|
||||||
parser.on("configure", "Initialise the configuration") do
|
|
||||||
init_config
|
|
||||||
end
|
|
||||||
parser.on("report", "Process and report spam email (default: from STDIN)") do
|
|
||||||
process_email_spam
|
|
||||||
end
|
|
||||||
parser.on("--help", "-h", "show this help") do
|
|
||||||
puts parser
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def parse_arguments(args : Array(String))
|
|
||||||
@option_parser.parse(args)
|
|
||||||
rescue e : OptionParser::Exception
|
|
||||||
puts e.message
|
|
||||||
puts @option_parser
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
private def init_config
|
|
||||||
print "Enter username: "
|
|
||||||
username = gets.try &.strip || "anonymous"
|
|
||||||
print "Enter password: "
|
|
||||||
password = gets.try &.strip || "anonymous"
|
|
||||||
create_config_file(username, password)
|
|
||||||
puts "Configuration file created."
|
|
||||||
end
|
|
||||||
|
|
||||||
private def process_email_spam
|
|
||||||
email_spam = STDIN.gets_to_end
|
|
||||||
|
|
||||||
signalspam = Providers::SignalSpam.new
|
|
||||||
signalspam.process(email_spam)
|
|
||||||
|
|
||||||
puts "Email spam processed."
|
|
||||||
end
|
|
||||||
|
|
||||||
private def create_config_file(username : String, password : String)
|
|
||||||
signalspam = Providers::SignalSpam.new
|
|
||||||
signalspam.create_config_file(username, password)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# Partie 1: Lecture du fichier de configuration YAML
|
||||||
|
config_path = File.expand_path("~/.config/signalspam/config.yaml", home: ENV["HOME"])
|
||||||
|
begin
|
||||||
|
config = Config.from_yaml(File.read(config_path))
|
||||||
|
rescue ex
|
||||||
|
puts "Error reading or parsing config file: #{ex.message}"
|
||||||
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
client = SignalSpamCtl.new
|
# Partie 2: Lecture de l'email-spam depuis STDIN
|
||||||
client.parse_arguments(ARGV)
|
email_spam = STDIN.gets_to_end
|
||||||
|
|
||||||
|
# Partie 3: Authentification sur signal-spam.fr
|
||||||
|
def authenticate(config : Config)
|
||||||
|
# Logique d'authentification (à compléter)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Partie 4: Remplissage et envoi du formulaire
|
||||||
|
def submit_spam_report(email_spam : String, config : Config)
|
||||||
|
# Logique pour remplir et envoyer le formulaire (à compléter)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Exécution des fonctions
|
||||||
|
authenticate(config)
|
||||||
|
submit_spam_report(email_spam, config)
|
||||||
|
|
||||||
|
puts "#{SCRIPT_NAME} v#{SCRIPT_VERSION} executed successfully."
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
module Providers
|
|
||||||
abstract class Abstract
|
|
||||||
abstract def process(email_content : String)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,73 +0,0 @@
|
||||||
|
|
||||||
require "../config"
|
|
||||||
require "./abstract"
|
|
||||||
|
|
||||||
module Providers
|
|
||||||
class SignalSpam < Abstract
|
|
||||||
|
|
||||||
property config : Config? = nil
|
|
||||||
|
|
||||||
def initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
def process(email_content : String)
|
|
||||||
load_config
|
|
||||||
agent = Mechanize.new
|
|
||||||
authenticate(agent)
|
|
||||||
submit_spam_report(agent, email_content)
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_config_file(username : String, password : String)
|
|
||||||
auth = Authentication.new(username: username, password: password)
|
|
||||||
config = Config.new(authentication: auth)
|
|
||||||
config_path = File.expand_path("~/.config/bulkbarrage/config.yaml", home: ENV["HOME"])
|
|
||||||
FileUtils.mkdir_p(File.dirname(config_path))
|
|
||||||
File.write(config_path, config.to_yaml)
|
|
||||||
end
|
|
||||||
|
|
||||||
private def load_config
|
|
||||||
config_path = File.expand_path("~/.config/bulkbarrage/config.yaml", home: ENV["HOME"])
|
|
||||||
begin
|
|
||||||
@config = Config.from_yaml(File.read(config_path))
|
|
||||||
rescue ex
|
|
||||||
puts "Error reading or parsing config file: #{ex.message}"
|
|
||||||
exit(1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private def authenticate(agent)
|
|
||||||
# Visiter la page de connexion pour obtenir le token d'authenticité
|
|
||||||
login_page = agent.get("https://signalants.signal-spam.fr/login")
|
|
||||||
form = login_page.forms.first
|
|
||||||
authenticity_token = form.field_with("authenticity_token").value
|
|
||||||
puts "Authentication page loaded."
|
|
||||||
|
|
||||||
# Configurer les détails de l'utilisateur
|
|
||||||
config = @config
|
|
||||||
return if config.nil?
|
|
||||||
|
|
||||||
form.field_with("user[email_or_login]").value = config.authentication.username
|
|
||||||
form.field_with("user[password]").value = config.authentication.password
|
|
||||||
# form.field_with("authenticity_token").value = authenticity_token
|
|
||||||
|
|
||||||
# Soumettre le formulaire
|
|
||||||
result_page = agent.submit(form)
|
|
||||||
raise "Unable to authenticate" if result_page.nil?
|
|
||||||
puts "Authenticated."
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
private def submit_spam_report(agent, email_spam : String)
|
|
||||||
report_page = agent.get("https://signalants.signal-spam.fr/reportings/new")
|
|
||||||
form = report_page.forms.first
|
|
||||||
authenticity_token = form.field_with("authenticity_token").value
|
|
||||||
puts "Reporting page loaded."
|
|
||||||
|
|
||||||
form.field_with("reporting[raw_email]").value = email_spam
|
|
||||||
result_page = agent.submit(form)
|
|
||||||
raise "Unable to submit" if result_page.nil?
|
|
||||||
puts "Reporting sent."
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Add table
Reference in a new issue