Solved

Linux Port Listen port 43, local whois server

Posted on 2001-09-05
11
655 Views
Last Modified: 2012-06-21
Hi,

I configure my linux to receive whois requests.
What I want is,
when a user did
"whois such-a-domain.com@whois.my-domain.com"
This script should be return the value after whois, namely
"such-a-domain.com@whois.my-domain.com".
To do this, I think I need to listen the whois port 43.

Anybody have/know? a C program which returns this...

Waiting for your answers...
0
Comment
Question by:Ege
  • 6
  • 5
11 Comments
 
LVL 2

Expert Comment

by:bkdc
Comment Utility
there were tons of questions on socket programming so, please, be more specific.
 What do you need ? a tutorial on sockets,TCP/IP, etc ?
0
 
LVL 1

Author Comment

by:Ege
Comment Utility
Hi again,
I need the following.
As everybody know, there exists a WHOIS SERVER (not client)

I configure my linux to accept whois requests via the port 43 (default whois port in RedHat).

With this configuration, if a whois request received, linux system runs the code /usr/sbin/in.whoisd
I will put my own executable instead of default one.

I want a C/C++ program to put this in.whoisd executable, such that, it understands the request.

Sample request:
whois subdomain.mydomain.com@whois.mydomain.com

whois.mydomain.com is my machine of course, and

subdomain.mydomain.com is a sub domain of my domain[s].

What I want is understanding the left part of @
(means subdomain.mydomain.com).

Such that, I can process my SQL queries and print the result...

In fact, the function not realy required to be a C code, it can also be a shell script or some other. But I prefer C.

Thanx for your interest...
0
 
LVL 2

Expert Comment

by:bkdc
Comment Utility
>>What I want is understanding the left part of @
(means subdomain.mydomain.com).

What do you want to understand ?
You mean you need help parsing the "whois subdomain.mydomain.com@whois.mydomain.com" stuff (read string) ?
 Is this what you want:
1. parse the string
2. get the subdomain string
3. search for it somethere
4. return stuff ?
0
 
LVL 1

Author Comment

by:Ege
Comment Utility
Yes.
Absolutuley yes.

Details:

filename: xinetd.d/whois
service whois
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.whoisd
}

And system calls
/usr/sbin/in.whoisd in time a request accepted.

I want to get the string whois subdom@whois.mydom.com

Rest is easy!

I tried with PERL and C using the SOCKET programming.

I got "address already in use" !

have any utility, which gets that string into a variable?

best regards...

0
 
LVL 2

Expert Comment

by:bkdc
Comment Utility
First of all, I strongly advise you to take a look (a closer look) at the following address:

http://community.roxen.com/developers/idocs/rfc/rfc1714.html

>>I got "address already in use" !

 Whois service is (usually) running on port 43. Since that port is already taken by the default /usr/sbin/in.whoisd
it's normal not to be able to establish a listening socket on that port. In fact, the port is taken up by inetd, which listens for requests and passes the control to in.whoisd when required (that is - when a request comes on port 43).

The inetd daemon forks and executes a copy of in.whoisd, the daemon associated with the whois service, handing the open file descriptor for the incoming socket connection to the new whois daemon.

After you get the handle, first thing you should do is to create a socket using that handle (attach to it).
Read the data after that.

Parsing the text should be no problem but if you have difficulties post the code and we'll help you.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 2

Accepted Solution

by:
bkdc earned 300 total points
Comment Utility
Oh, one more thing. I'm not very familiar with Linux (I guess that's what you're using) cause I use QNX which is slightly different but I think that you should make some changes in xinetd.d/whois or whatever.

filename: xinetd.d/whois
service whois
{
       disable         = no
       socket_type     = stream
       wait            = no
       user            = root
       server          = /usr/sbin/in.ege.whoisd
}

That way inetd will call your program instead of the default in.whoisd
0
 
LVL 1

Author Comment

by:Ege
Comment Utility
well,

it 's clear that, no  socket connection and listenning required... which is already done by standart whois service, via the INET.

(unfortunately, in.whoisd and in.ege.whoisd the same thing in your sample! just changing the filename! here).

--------------- IMPORTANT PART --------------------
in this case, what I need is:
only the getting string into a VARIBLE.
string is the requested one by user, i.e
"whois subdom.mydom.com@whois.mydom.com"
inside the file /usr/sbin/in.whoisd
which is called each time whois request accepted via INET services...
--------------------------------------------------

{ the URL you give talks about the WHOIS, but I do NOT wanna use standart whois process.. I just one to use it as a known process to accept queries! }

thanx for your interest... but still I do not get my answer.

best regards...
0
 
LVL 2

Expert Comment

by:bkdc
Comment Utility
I understand, but the only way to do that is to write a whois daemon (in.ege.whoisd or whatever name you like) and use it instead of the default one: in.whoisd
0
 
LVL 1

Author Comment

by:Ege
Comment Utility
:)

yes! but how!?

my problem is already accepting the requested string!

If I can get the string sent by whois command, I have no problem to process it!

How can I get the string which has been sent by whois command?

:)
0
 
LVL 2

Expert Comment

by:bkdc
Comment Utility
Told ya before. Make a nice little daemon. There's no other way, unless you use a sniffer (and that would be a REAL pain).
 Why do you find it so difficult ? Take some in.whoisd sources (i presume Linux comes with this king of source code) and tweak it to serve your needs. This way you won't have to write a fully compliant whois daemon from scratch.

PS: Sorry but I don't know any other (easy, hocus-pocus, 10 easy steps) way.
0
 
LVL 1

Author Comment

by:Ege
Comment Utility
sorry that I accept your answer due the personel problems.
Thatks for your interest. Your answer about xinet.d configuration file did help me...
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now