EvilZone

Hacking and Security => Hacking and Security => Topic started by: cyberdrifter on February 01, 2015, 10:36:57 PM

Title: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 01, 2015, 10:36:57 PM
I'd like to start a thread that shares potentially useful tricks and tips within the security realm that others could benefit from. Whether they're simple terminal tricks, simple or complex googlefu, obscure commands, short programs, novel ways of doing something, or a simple exploits.

The idea is to share something short and sweet that doesn't require a lot of explanation (nothing more than a couple of paragraphs at most.) and to be clear, we're looking for quick, clear, concise commands. Not links to pages or general ideas. Show us what you've found useful.

For instance:

A Simple Terminal Ping-Sweep
Code: [Select]
for i in {1..254}; do ping -c 1 -W 1 192.168.0.$i | grep 'from'; done This short terminal command can be used when you don't have access/want to avoid the bulk of more well established programs. Simply creates a forloop that iterates through a given IP range and pipes the output to grep. (Modify the IP as needed)




*WARNING* I suggest you test all suggestions in a VM before using them on your actual system... Never know what some Asshole might throw up here, on purpose or out of ignorance (to include myself). Trust be verify.


=============List of Shared Commands========================

Return a list of Dynamically linked SUID/GUID programs (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99517/#msg99517)   

       Alternate method (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99565/#msg99565)
Simple Python HTTP Server (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99521/#msg99521)
Delete files by extension (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99526/#msg99526)
       Alternate method (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99533/#msg99533)
Google searches by filetype (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99526/#msg99526)
Determine your public IP address (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99593/#msg99593)
Add files to pastebin using the terminal (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99595/#msg99595)
Mount a partition in RAM for temp/volatile storage (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99602/#msg99602)
Rerun a command with Sudo privileges (without retyping the command) (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg99870/#msg99870)
Show list of open network connections that updates each second (https://evilzone.org/hacking-and-security/short-and-sweet-tips-and-tricks/msg101174/#msg101174)
Title: Re: Short and Sweet - Tips and Tricks
Post by: HTH on February 01, 2015, 11:05:18 PM
Code: (python) [Select]
import commands;
for each in str(commands.getstatusoutput("find / -perm +6000 -type f -print 2>/dev/null")[1]).split('\n'):
    print each + '\n' + str(commands.getstatusoutput("ldd " + each)[1]) + '\n'

Returns a list of SUID/GUID programs that are dynamically linked, as well as the libs they link to

Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 01, 2015, 11:22:57 PM
A stupid simple Python HTTP Server

Quote
python -m http.server

This is actually a very useful/dangerous little script I use often. All it does is use pythons simple built in HTTP server and opens up a window on port 8000 (by default). If you're already on the box and need a quick window out. From here you use your distant machine to browse to the target machines i.e.:192.168.0.2:8000 and it works like a charm.
Title: Re: Short and Sweet - Tips and Tricks
Post by: Syntax990 on February 02, 2015, 12:56:39 AM
On bash, zsh and sh; You can delete files within a directory by file extension type.

Code: [Select]
$ ls
init.py conf.py libdevin.c

$ rm !(*.c|*.py)
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 01:28:55 AM
On bash, zsh and sh; You can delete files within a directory by file extension type.

Code: [Select]
$ ls
init.py conf.py libdevin.c

$ rm !(*.c|*.py)
Using a similar principle you can do google searches by file extention, for example.

In order to find the book Blackhat Python with google:

Code: [Select]
blackhat python filetype:pdf
This will do a search in google with your key terms up front i.e. the title of the book, and the filetype: operator allowing us to return ONLY PDF's that meet our criteria.



Which links us to blackhat python:
http://greysec.ir/ebook/Black.Hat.Python.Python.Programming.for.Hackers_%5Bwww.graymind.ir%5D.pdf (http://greysec.ir/ebook/Black.Hat.Python.Python.Programming.for.Hackers_%5Bwww.graymind.ir%5D.pdf)
As our first result.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 02:01:26 AM
On bash, zsh and sh; You can delete files within a directory by file extension type.

Code: [Select]
$ ls
init.py conf.py libdevin.c

$ rm !(*.c|*.py)
I'd probably suggest using this method:

Quote
rm {*.c,*.py}
You know... less to type and all :P
Title: Re: Short and Sweet - Tips and Tricks
Post by: madf0x on February 02, 2015, 10:54:43 AM
Code: (python) [Select]
import commands;
for each in str(commands.getstatusoutput("find / -perm +6000 -type f -print 2>/dev/null")[1]).split('\n'):
    print each + '\n' + str(commands.getstatusoutput("ldd " + each)[1]) + '\n'

Returns a list of SUID/GUID programs that are dynamically linked, as well as the libs they link to

or you could just use -exec like so:

Code: [Select]
find / -perm +6000 -type f -exec ldd {} \; -print 2>/dev/null

similarly find all world writable files and directories(nasty priv esc potentials):
Code: [Select]
find / -perm -2 ! -type l -ls

for when you don't care about noise, but want easy fast scanning backed by nmaps versioning:

https://github.com/superkojiman/onetwopunch





Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 05:43:24 PM
Determine what your address appears to be from the outside.
Code: [Select]
curl ifconfig.me
Title: Re: Short and Sweet - Tips and Tricks
Post by: gray-fox on February 02, 2015, 06:27:18 PM
Terminal pastebin with netcat, examples:
Code: [Select]
echo 'test' | nc termbin.com 9999
cat file.txt | nc termibin.com 9999
..and you receive link for your pasted text.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 06:42:52 PM
Terminal pastebin with netcat, examples:
Code: [Select]
echo 'test' | nc termbin.com 9999
cat file.txt | nc termibin.com 9999
..and you receive link for your pasted text.
Nice one, I saw that site a while back but forgot about it... Thanks
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 07:06:25 PM

Mount Termporary Partition in RAM:
Code: [Select]
mount -t tmpfs tmpfs /mnt -o size=1024m

In the case that you need to store something shady on your computer for a short time. Storing it in volatile ram makes it easier to securely dispose of.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 02, 2015, 10:37:08 PM
Found a page that a few of you might like:
http://www.tuxradar.com/content/linux-tips-every-geek-should-know (http://www.tuxradar.com/content/linux-tips-every-geek-should-know)
I'm sure we all have pages link this we could share, but the intent is to filter out the best ones and offer them up, with a brief explanation.
Title: Re: Short and Sweet - Tips and Tricks
Post by: HTH on February 03, 2015, 12:39:24 AM
or you could just use -exec like so:

Code: [Select]
find / -perm +6000 -type f -exec ldd {} \; -print 2>/dev/null

you could yes but the logs created are different that's all, i took that from a larger script though, thats the main reason its in pythong :p
Title: Re: Short and Sweet - Tips and Tricks
Post by: HTH on February 03, 2015, 02:43:27 AM
Typo, or you just don't like python? lol

http://www.pythong.org/ (http://www.pythong.org/)

nah calling it pythong just makes me laugh
Title: Re: Short and Sweet - Tips and Tricks
Post by: Matriplex on February 03, 2015, 04:03:27 AM
For fucks sake I did something like this a few months ago.. it never took off.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 03, 2015, 04:11:18 AM
For fucks sake I did something like this a few months ago.. it never took off.
Gotta link? I'd like to see your offerings.
Title: Re: Short and Sweet - Tips and Tricks
Post by: Matriplex on February 03, 2015, 05:20:42 AM
Nobody replied to the thread... I had something on there to do with Java for a kick starter I think. It's not important.
Title: Re: Short and Sweet - Tips and Tricks
Post by: Spectrum_963 on February 03, 2015, 11:54:44 AM
Here's a tip, familiarize yourself with the sh mod in python. Sure you've for the os mod that can already do a lot of the things the sh mod can but I've found it extremly useful so far.
Sticky, anyone?

@Matriplex - more people fiddle with python and bash than with java. It's only natural.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 03, 2015, 04:18:18 PM
Here's a tip, familiarize yourself with the sh mod in python. Sure you've for the os mod that can already do a lot of the things the sh mod can but I've found it extremly useful so far.
The idea was to post specific commands, do you have a brief example to justify why you think the sh mod is useful?
Title: Re: Short and Sweet - Tips and Tricks
Post by: Deque on February 05, 2015, 08:28:26 AM
Sometimes I want to fetch x number of files from a larger file base.
The following command copies 1000 files randomly from the current folder to the dest folder

Code: [Select]
ls . | shuf -n 1000 | xargs -i -t cp {} dest
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 05, 2015, 05:55:21 PM
Bang Bang:

This is an incredibly simple command, that I'm always surprised to see people don't know, so:

Code: [Select]
$ make sandwich
error: you cannot perform this operation unless you are root.
$ sudo !!
Ofcourse I'll make you a sandwich!

For instance when you run a command that requires admin privs (but forgot to type sudo), instead of typing the whole command again, just use two exclamations to represent your previous command.
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 27, 2015, 03:57:49 AM
Create list of network connections that updates every second, it will tell you:
Code: [Select]
watch -n 1 lsof -i -P

Breakdown

Watch - Executes a program periodically.
    -n 1 - this switch tells Watch to run at an interval of once every 1 second


lsof      -This program is used to list open files (everything's a file in linux... even connections)
    -i      -This tells lsof to only list network/internet related files
    -P     -This tells lsof to tells lsof to list port numbers instead of converting them to the human readable form (ie it will show 80 instead of HTTP), this helps speed up the command.


Title: Re: Short and Sweet - Tips and Tricks
Post by: Darkvision on February 27, 2015, 07:36:51 AM
soo ill change things up and toss out a Win tip/trick :)

Always have some form of " Preinstallation Environment"(PE) both on disk(cd/dvd) and USB. I also like to tack on my favorite "must have" softwares onto the image/USB such as a virus scanner, malware remover etc. For XP and before BartPE is my hands down favorite, but since they stoped releasing you either have to pay(or get cracked) for a winternals version or get the WinPE as your two best choices. To iterate just a "few" uses:File recovery, password changing, system monitoring. 
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on February 27, 2015, 09:39:53 PM
soo ill change things up and toss out a Win tip/trick :)

Always have some form of " Preinstallation Environment"(PE) both on disk(cd/dvd) and USB. I also like to tack on my favorite "must have" softwares onto the image/USB such as a virus scanner, malware remover etc. For XP and before BartPE is my hands down favorite, but since they stoped releasing you either have to pay(or get cracked) for a winternals version or get the WinPE as your two best choices. To iterate just a "few" uses:File recovery, password changing, system monitoring.
To reiterate what was said in the original post in this thread:
we're looking for actual commands.

That are: short, concise, and can be quickly explained.


Do you have an example of a command that you'd use with this method?
Title: Re: Short and Sweet - Tips and Tricks
Post by: cyberdrifter on March 19, 2015, 05:20:34 PM
Simple ROT13 Encoding function
Code: [Select]
rot13()
{
echo "$@" | tr '[a-m][n-z][A-M][N-Z][0-4][5-9]' '[n-z][a-m][N-Z][A-M][5-9][0-4]'
}

The above function can be added to your .bashrc for ease of use (or as a stand alone script).



Once in your sourced bashrc simply type:
Code: [Select]
rot13 "whatever you want to encode" (without quotes) and your string will be encoded.
You can use this to encode whole files replacing echo with cat in the above code in which case you'd use
Code: [Select]
rot13 "Nameoffile.txt"

To decode simply input the encoded message back into rot13 and it reverses the process.



One way that someone could use this is a simple method to additionally harden passwords. If for instance you use pass phrases with real words, this will help garble those words up which will help prevent dictionary attacks. While allowing you to have a simple way to encode/decode them.


WARNING: This is NOT encryption, it is a simple encoding method, and it is not a secure method to transfer sensitive information. This is just a simple shift cipher that can help you with in very specific situations.