Home

Forums

Web development

 

 

 

 
     
 
dna88 Web development and Technology Forum
 
Profile   Register   Memberlist   Usergroups   FAQ   Search  Log in
The principles of Connecting to Daemon or How daemon works?

 
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum
Author Message
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: The principles of Connecting to Daemon or How daemon works? Reply with quote

Has anyone ever worked with daemons?

This daemon I am talking about basically guards a database and decides upon which IP address can connect to the database with what priveleges.

So I need some pointer as to how to connect with a daemon? The rest is easy. Any good article on daemon would be nice as a beginner. Is the IP address is enough to connect to the daemon? What header information needs to be sent to the daemon?
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.


Last edited by quantum on Fri Jun 04, 04 2:59 am; edited 1 time in total
Fri Jun 04, 04 1:33 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
Tousif
Beginner User
Beginner User


Joined: 25 May 2004
Posts: 20
Location: Nashville, Tennessee, USA

Post Post subject: Reply with quote

Hi,
I once programed a security deamon for fun -honeyd. Its pretty much the best out there in its field I think. Since I've never worked in database I don't know if this would be relevent to your work but you can check out this website -

[http://www.citi.umich.edu/u/provos/honeyd/]

you will see articles regarding how to connect -it's very easy with honeyd (The article "deploying honeyd in the wild" and the very last one -"open source honeypots" by Lance Spitzer has some examples). I can guarantee, once you know how to use it, you will fall in love with it.

Hope this will be helpful.

Tousif
Fri Jun 04, 04 2:37 am
Back to top
Tousif View user's profile Send private message
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

Thank you Tousif.

I am checking it out. In the meantime I have another question. How can you basically convert a .c C program into a windows version?

Are the definitions and functions of the unix version usually compatible and exportable to windows version?

I am basically interested in converting something like this to something that will work with a windows application:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>

int client_query (struct query_struct *q)
{
  char dmcBuffer[MAX_STRING_SIZE], *p = NULL;
  int recvMsgSize = 0x00;
  int sock, ret = TRY_LATER;
  struct sockaddr_in dmdServAddr;
  int msgLen = 0x00, done = 0x00;
  char msgString[MAX_STRING_SIZE];

  if (sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) {
    /* construct server address structure */
    memset (&bmdServAddr, 0x00, sizeof (bmdServAddr));
    dmdServAddr.sin_family = AF_INET;
    dmdServAddr.sin_addr.s_addr = inet_addr (q->bmd_server_ip);
    dmdServAddr.sin_port = htons (BMD_LISTEN_ON);

    /* Connect to daemon*/
    if ((connect (sock, (struct sockaddr *) &dmdServAddr, sizeof (dmdServAddr))) == 0x00) {
      memset (&bmcBuffer, 0x00, sizeof (bmcBuffer));


      if ((recvMsgSize = recv (sock, dmcBuffer, sizeof (dmcBuffer) - 1, 0)) > 0) {
        dmcBuffer[recvMsgSize] = 0x00;
        /* We need to skip past the initail '\n', the numeric code, and the
           space, to get to the banner proper.
         */
        strcpy (msgString, chomp (dmcBuffer));  /* msgString reused */
        p = msgString;
        while (*p != 0x20)
          p++;
        strcpy (dmcBuffer, ++p);

        msgString[0] = 0x00;


Is it possible?
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Fri Jun 04, 04 2:42 am
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
Tousif
Beginner User
Beginner User


Joined: 25 May 2004
Posts: 20
Location: Nashville, Tennessee, USA

Post Post subject: Reply with quote

Hi quantum,

Well...one thing for sure is that windows doesn't have quivalent library for unistd.h. For sockets, you have to use windows socket library.


However, if you want your code to be platform independent, you have to use #ifdefs to conditionally inclide libraies and execute parts of your code depending on the platform its running on.


Thats the only solution I could think of for the code you've provided..use #ifdef's and rewrite it to make it platform independent.

Hope this helps.

Tousif
Sat Jun 05, 04 5:16 am
Back to top
Tousif View user's profile Send private message
quantum
Site Admin
Site Admin


Joined: 07 Mar 2004
Posts: 1048
Location: Dhaka, Bangladesh

Post Post subject: Reply with quote

You are absoltely right. There are exact equivelent functions for socket.h But unistd.h is solely unix property. In windows this function is somewhat mimicked with process.h. But the way this is implemented is totally different.

The application is question is windows based, so I am not worried about platform independency. I am working on to rewrite the whole code in C for windows and implement the functionality without worrying about the exact conversion.

Thanks.
_________________

Dust fills my eyes / Clouds roll by / and I roll with them / Centuries cry / Orders fly / and I fall again
Afford best design, implement best solution. Outsource your web design.
Sun Jun 06, 04 1:07 pm
Back to top
quantum View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    dna88 Forum Index -> Programming in Java, C, C#, VB, .NET Discussion Forum All times are GMT - 7 Hours
Page 1 of 1

 

Partners and Resources

Bangladesh hosting company

Bangladesh web design

Driven by phpBB © phpBB Group