FightingMan's FootPrints

I know the only way to success for me is do it forever and never give up.

A Trap in Php Base_convert

| Comments

Today I find an interesting thing: a php function base_convert

convert.php
1
2
$a = 0x80;
var_dump(base_convert($a, 16, 2));

No surprises:

string(9) "100101000"

Let’s go on!

convert.php
1
2
3
4
$a = 0x80;
var_dump(base_convert($a, 16, 2));
$b = ~$a;
var_dump(base_convert($b, 16, 2), $b);

output:

string(9) "100101000"
string(9) "100101001"
int(-129)

Hmm,it seems strange that binary 100101001 not equas decimal -129, but the result: -129 is the right answer,what happened?

Shell Tips With Ctrl+(?)

| Comments

There are some handy operator with command line:

[Ctrl-d] #This exits shell or closes input on programs waiting for STDIN.NOTE: there must be no such thing as an end of file character.
[Ctrl-z] #This suspend a process u r running in foreground. Get it back by running 'fg', background it using 'bg'.
[Ctrl-c] #This canceling a running program,Ctrl-C can be used before you run cammand to "cancel" the line edit and start anew.
[Ctrl-b] #Move to the begging of the current or previous word. NOTE: base on keyboard mapping sometimes.
[Ctrl-f] #Move to the end of the current or next word. NOTE: base on keyboard mapping sometimes.
[Ctrl-w] #Remove the previous word.
[Ctrl-l] #Clear screen.
[Ctrl-K] #Delete/Yank everything from cursor to the end of line.
[Ctrl-U] #Delete/Yank everything from cursor to the begging of the line.
[Ctrl-e] #Move your cursor to the end of the line.
[Ctrl-a] #move your cursor to the begging of the line.
[Ctrl-r] #Reverse search through your command history for 'input'. ESC when done.
[Ctrl--] #Manial lists this as Ctrl-_ but Ctrl-- ususally works too.Incremental undo of command line edits.

Look forward to your supplementary :).

My Girl Friend

| Comments

I pursued a girl for six years whose name is Rever the most beautiful girl in the world.

In Dec. 22, We fell in love :).

Thanks to Mayans that they can only help me so much,if without their help I think I’ll lose myself.

I’m not good at talking and writting,but you must know Rever you’er my only princess all the time,I’ll guard you to the old.

I’ll realizing all your dreams,you must be the happiest girl in the world.

Other words,now we’er not together in the same place,wait and give me some time,I’m standing by my words,the line must be fruit.

Anyway,I feel I’m the happiest man in these days,miss you Rever,I think I’m so lucky.

An Interesting Thing Occurs While a Class Inside Interface

| Comments

While I’m putting class inside interface with anonymous,something interested occurs.

As21.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
interface Comm {
    class Inner implements Comm {
        static void f(Comm c) {
            c.v();
        }
        public void v() {}
    }

    public void v();
}

interface Diff {
    class Differ implements Comm {
        static void g(Comm c) {
            c.v();
        }
        public void v() {}
    }
}

public class As21 {
    public static void main(String[] args) {
        Comm c = new Comm() {
            public void v() {
                System.out.println("as21");
            }
        };
        Comm.Inner.f(c);
    }
}

class As22 implements Comm {
    public void v() {
        System.out.println("as22");
    }

    public static void main(String[] args) {
        As22 a = new As22();
        Inner.f(a);
        Diff.Differ.g(a);
    }
}

As you can see,As21 is the one which I wantted,but the interesting thing occurs in As22. First,any class you put inside an interface is automatically public and static. Then As22 implements the Comm interface so it can call f() method directly with using Inner.f() witout Comm in front of it, but the method f() in Diff interface cannot called directly,must use Diff.differ.f().

In addition,how to execute the program in command line while put classes inside interfaces?

e.g.

As20.java
1
2
3
4
5
6
7
8
9
10
11
interface As20 {
    class Inner implements As20 {
        public String toString() {
            return "test";
        }
        public static void main(String[] args) {
            Inner i = new Inner();
            System.out.println(i);
        }
    }
}

javac As20.java

java As20\$Inner

Connect to Postgresql via Msfconsole in Metasploit

| Comments

Today I’m testing metasploit in bt5,there is a problem takes me some time,yes,this is a bug,show these codes:

root@bt:~# cd /opt/metasploit/
root@bt:/opt/metasploit# cat config/database.yml 
    development:
    adapter: "postgresql"
    database: "msf3dev"
    username: "msf3"
    password: "4bfedfc2"
    port: 7337
    host: "localhost"
    pool: 256
    timeout: 5

    production:
    adapter: "postgresql"
    database: "msf3dev"
    username: "msf3"
    password: "4bfedfc2"
    port: 7337
    host: "localhost"
    pool: 256
    timeout: 5
root@bt:/opt/metasploit# netstat -tunpl | grep postgres
tcp        0      0 127.0.0.1:7337          0.0.0.0:*               LISTEN      1321/postgres.bin
tcp6       0      0 ::1:7337                :::*                    LISTEN      1321/postgres.bin
root@bt:/opt/metasploit# cd msf3
root@bt:/opt/metasploit/msf3# ./msfconsole

# cowsay++
 ____________
< metasploit >
 ------------
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *


       =[ metasploit v4.5.0-dev [core:4.5 api:1.0]
+ -- --=[ 927 exploits - 499 auxiliary - 151 post
+ -- --=[ 251 payloads - 28 encoders - 8 nops

msf > db_connect msf3:4bfedfc2@localhost:7337/msf3dev
      [-] No database driver installed. Try 'gem install pg'

msf3 is the username in database.yml; 4bfedfc2 is the password in database.yml; msf3dev is the database in database.yml; and the 7337 is the port for postgresql.