Thursday 3 March 2011

What coding language should I begin with?

What coding language should I pick to start coding spy programs?

That's the question I hear most:
What coding language should I pick to start coding spy programs?

By experience, I started with Visual Basic 5, in 1999. Even though I didn't use Windows APIs (Application Programming Interface) I liked the easiness that coding in VB5 was. But you can't go much further without using Windows API, that's what spy programming is all about. With the APIs you will be able to code virtually anything (no pun intended). I found later that VB COULD call APIs, then I changed to VB 6. I managed to make my first "internet" programs, like Ghostvoice. It was connecting to an IP, sending and receiving data! But I was using 2 API calls, and the rest, I relied in VB OCX controls, Winsock + direct speech. Yuck, if the remote computer doesn't have the OCX or even, the VB runtimes, your program will CHOKE, by the means, it won't even start.

So I saw that VB wasn't really my thing, and fastly moved to Delphi 5, and since then I settled forever. Delphi makes it perfect for malware coding, since you don't need any external requirements, only it being Windows OS. It's basically APIs all over, you won't be doing anything else, apart from the VCL, that is a wrapper for visual Windows API, like CreateWindow(), SetForegroundWindow(), ShowWindow(), CallWndProc(), etc. Delphi is pretty easy to learn and it's very intuitive.

It's almost like talking to the code, where you want a piece of code that does something, you do:

procedure DoMyStuff(var MyStuff);
begin
ProcessStuff(MyStuff);
end;

As you can see, there are BEGIN and END blocks, code that doesn't return a value are "PROCEDURE"'s and code that return a value are "FUNCTION"'s. So, before anybody ask, yes I would for sure recomend you starting with Delphi. Then after you grasp your handles with Delphi (pun intended) you can move to C++, and who knows, an ASM compiler such as FASM or NASM (my favorite).

By now, I would not recomend .NET (any 'sharp' language), since it also relies on a framework, that needs to be pre-installed on the computer.
Get coding, you can even try a free IDE called Lazarus, that is for Object Pascal, at
Author: caesar2k
www.lazarus.freepascal.org

How to get requested controller name, action name and id in Rails3 view

To get requested controller name, action name and id in view we will call a simple helper function. For example we have the '/users/show/23' request, by routing rule: 'match ':controller(/:action(/:id(.:format)))''
#to get controller name:
<%= controller.controller_name %>
#=> 'users'
#to get action name, it is the method:
<%= controller.action_name %>
#=> 'show'
#to get id information:
<%= ActionController::Routing::Routes.recognize_path(request.url)[:id] %>
#=> '23'

Each loop for a class or model instance variables


Sometimes we need to check all of instance variables in a class or model one by one. In this exaple we will check if a varaible is an Array or not:

your_model.instance_variables.each do |i|
if your_model.instance_variable_get(i).instance_of?(Array) then
#your code to do anything with your_model.instance_variable_get(i) what is a value
end
end

If you have an active record model, you can do:

@account = Account.first
Account.column_names.each do |i|
@account.instance_eval(i)
# row returns @account.name for example inside the loop, next @account.address and so on
end


submit an ajax form in javascript winth Rails3 and Prototype

So there is a Rails 3 problem, when you want to submit a form in javascript (without a submit button), it is working on normal way, not ajax. But we can do creating a hidden submit button and then initializing a click event on it what is exactly doing ajax submission. The submit(); is not working anymore because it doesn't call the rails.js functions. It just works when you simple want to create a not ajax post without any confirmation. Let's see an ajax example in view's index.html.erb file:




<%= javascript_tag <<-RUBY
function procedure_init()
{
var submit_button="procedure_submit_button";
var form_name="some_procedure";
// here you can build the form, or modify form parameters
$(submit_button).click();
}
RUBY
%>
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
<%= form_tag "some_url",
:remote => true,
:method => :post,
:name => "some_procedure",
:id => "some_procedure" %>
<%= submit_tag 'procedure_submit_button', :id =>"procedure_submit_button" , :style => "display: none" %>
You can add here your html code for form and create some element what is doing the submission inside a table, for a td:
"javascript: procedure_init();" style="cursor: pointer;">
put here an image for example


That's all. Questions?

Thursday 17 February 2011

Class with all the Overloaded Arithmetic Operators

So far we have learnt to overload +, -, +=, -= etc. operators and we know what is the basic theory behind operator overloading.

In this article we are going to design a program with a class that overloads almost all the arithmetic operators (+, -, +=, -=, /, *, ++, --)

This is a program centric article, so we straightway have a look at the example program.

Since nothing new has been introduced, I leave it up to you to understand everything yourself.


// Example Program with a
// a class having almost
// all the arithmetic
// operators overloaded
#include

class myclass
{
int a;
int b;

public:
myclass(){}
myclass(int,int);
void show();

myclass operator+(myclass);
myclass operator-(myclass);

// prefix
myclass operator++();
myclass operator--();

// postfix
myclass operator++(int);
myclass operator--(int);

myclass operator+=(myclass);
myclass operator-=(myclass);

myclass operator/(myclass);
myclass operator*(myclass);

};

myclass::myclass(int x,int y)
{
a=x;
b=y;
};

void myclass::show()
{
cout< }

myclass myclass::operator+(myclass ob)
{
myclass temp;

temp.a=a + ob.a;
temp.b=b + ob.b;

return temp;
}

myclass myclass::operator-(myclass ob)
{
myclass temp;

temp.a=a - ob.a;
temp.b=b - ob.b;

return temp;
}

myclass myclass::operator++()
{
a++;
b++;

return *this;
}

myclass myclass::operator--()
{
a--;
b--;

return *this;
}

myclass myclass::operator++(int x)
{
myclass old;
old=*this;

a++;
b++;

return old;
}

myclass myclass::operator--(int x)
{
myclass old;
old=*this;

a--;
b--;

return old;
}

myclass myclass::operator+=(myclass ob)
{
a+=ob.a;
b+=ob.b;

return *this;
}

myclass myclass::operator-=(myclass ob)
{
a-=ob.a;
b-=ob.b;

return *this;
}

myclass myclass::operator/(myclass ob)
{
myclass temp;

temp.a=a / ob.a;
temp.b=b / ob.b;

return temp;
}

myclass myclass::operator*(myclass ob)
{
myclass temp;

temp.a=a * ob.a;
temp.b=b * ob.b;

return temp;
}

void main()
{
myclass ob1(10,20);
myclass ob2(100,200);

ob1+=ob2;

ob1.show();
ob2.show();

ob1=ob1/ob2;
ob1.show();

ob1=ob1*ob2;
ob1.show();

ob2.show();
}

Overloading [] Operator in a class to access data within the class by indexing method.

In the previous article Overloading [] Operator, we overloaded the [] operator in a class to access data within the class by indexing method.

The operator [] function was defined as below:

  int myclass::operator[](int index)

{

// if not out of bound

if(index
return a[index];

}

As you can see, the above operator function is returning values, hence it could only be used on the right hand side of a statement. It’s a limitation!

You very well know that a statement like below is very common with respect to arrays:

a[1]=10;

But as I said, the way we overloaded the [] operator, statement like the one above is not possible. The good news is, it is very easy to achieve this.

For this we need to overload the [] operator like this:

  int &myclass::operator[](int index)

{

// if not out of bound

if(index
return a[index];

}

By returning a reference to the particular element, it is possible to use the index expression on the left hand side of the statement too.

The following program illustrates this:



// Example Program illustrating

// the overloading of [] operator

// ----

// now the index expression can be

// used on the left side too

#include



class myclass

{

// stores the number of element

int num;

// stores the elements

int a[10];



public:

myclass(int num);



int &operator[](int);

};



// takes the number of element

// to be entered.(<=10)

myclass::myclass(int n)

{

num=n;

for(int i=0;i
{

cout<<"Enter value for element "<1
<<":";

cin>>a[i];

}

}



// returns a reference

int &myclass::operator[](int index)

{

// if not out of bound

if(index
return a[index];

}



void main()

{

myclass a(2);



cout<0]<
cout<1]<


// indexing expression on the

// left-hand side


a[1]=21;

cout<1];

}



Monday 10 January 2011

When trying to connect to through filezilla I get the error 'Connection attempt failed with "ECONNREFUSED - Connection refused by server". I bypassed

When trying to connect to through filezilla I get the error 'Connection attempt failed with "ECONNREFUSED - Connection refused by server".

I bypassed the router, disabled all firewalls, and everything else I could think of. I eventually installed the program on my wife's laptop and it works perfect with the exact same program settings I have on mine.

What else could this problem be caused by?
The answer is that
Sounds to me like you have the wrong username or password. Servers will refuse connections if the correct user and password are not entered.
or
The ONLY reasons an FTP server will refuse the connection (other than the IP being blocked, which isn't the case here) is the wrong username or the wrong password (or both), or the initial directory is one you don't have access to