Newsgroup: it.comp.sicurezza.unix
Titolo: nbtstat e linux!

Ciao!
Cortesemente vorrei sapere se in linux esiste un programma tipo l'
nbtstat di windows.
Se si, magari se potete dirmi dove posso scaricarlo.
Grazie a tutti!

 nbtstat di windows.
sarebbe?
-- 
-andreas liebschner
 rimuovi NOSPAM. per rispondermi in email
powered by slackware linux

il giorno Sat, 12 Jan 2002 19:46:10 +0100, kubric ha fatto comparire
questi byte sul mio schermo:

netstat per visualizzare i socket aperti
netstat -r per visualizzare il routing
netstat -i che è come ifconfig
-- 
/****************************************/
/HomePage: 
http://accessdenied85.cjb.net
 /
/E-mail: .....access_denied[at]
libero.it
 /              *AccessDenied*
/****************************************/

nbtstat di windows.
nmblookup
-- 
s/nospam/daniel.kobza/
Warning: filesystem is EXT2 but user is FAT

 
Grazie della dritta Daniel, credo che il programma sia quello.
Ti chiedo ancora un' altra cosa, sai sono nuovo in linux e ci ho capito
poco delle varie opzioni e sintassi dell' nmblookup, vorrei sapere quale
sintassi devo usare per emulare quella che uso in windows=
NBTSTAT -A INDIRIZZO IP.
Grazie.

 ha scritto:

Scusami, ma credo di aver trovato la sintassi esatta del comando che
cerco, ma adesso ho un altro problema.
Per connettersi alla risorsa condivisa, in windows dopo nbtstat -A uso il netview, ma in
linux?
Scusa se insisto, ma ho bisogno di usare il programma.
Grazie!

linux?
smbmount oppure mount -t smbfs
Sul loro utilizzo, ti rimando alla man page.
Buttha

 Grazie!
Esiste un tool nbtstat. Eccoti il sorgente :
[inizio sorgente]
/*
 * lame nbtstat for linux, by Todd Sabin
Copyright (c) 2000 BindView Corporation.  All rights reserved.  
By using this software, YOU AGREE to the following license terms.  IF YOU 
DO NOT AGREE, YOU MAY NOT USE THE SOFTWARE.  
1.  BindView believes that this software is safe for use in normal 
circumstances, and has performed what it believes to be reasonable but 
non-exhaustive testing to verify this.  The software is intended for use 
only by experienced and knowledgeable computer professionals; IT IS 
PROVIDED "AS IS, WITH ALL FAULTS," including source code so that the user 
can study the source code and independently determine the software's 
suitability.  BindView makes no warranty of any kind, express or implied, 
and DISCLAIMS ANY AND ALL WARRANTIES, CONDITIONS, OR IMPLIED TERM OF 
QUALITY, INCLUDING THE IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.  All use of the 
software is entirely at the user's own risk.
2.  IN NO EVENT WILL BINDVIEW BE LIABLE FOR DAMAGES OF ANY KIND arising 
from or relating to use of the software, whether such damages are direct, 
indirect, incidental, consequential, exemplary, or any other kind, and 
whether arising under contract, tort (including negligence), strict 
liability, or otherwise.
3.  BindView will not object to your distribution of complete, unmodified 
copies of the distribution package of the software as provided by BindView, 
PROVIDED that you do not charge a fee other than a reasonable fee for 
distribution services.  You may charge a fee for any warranty or support 
services that you offer to purchasers of copies of the software.
4.  You may modify the software and distribute copies of the modified 
software, PROVIDED:
        (a) that you distribute, together with the executable code of the modified 
software:
 
                (1) the source code of the modified software, which must contain the 
BindView copyright notice set forth above (in addition to your own 
copyright notice if any); and
                (2) a copy of the complete, unmodified distribution package of the 
software as provided by BindView; and
        (b) that you clearly indicate in the source code and in an accompanying 
documentation file that the software is based on BindView's software and 
was modified by you; and
        (c) that you grant users of the modified software the same rights as are 
granted to you by this license.
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <setjmp.h>
#include <signal.h>
static void dump_bytes (unsigned char *p, size_t sz, int indent);
static void dump_node_status (unsigned char *p, size_t sz);
static void sig_alrm(int);
static jmp_buf env_alrm;
#define STATUS_REQ 
"\xa2\x48\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x20\x43\x4b\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x00\x00\x21\x00\x01"
int
main (int argc, char *argv[])
{
    int s;
    struct sockaddr_in s_addr, c_addr;
    char ms[1000];
    int sz;
    struct hostent *h;
    if (argc != 2) {
        fprintf (stderr, "Usage: %s <ip-address>\n", argv[0]);
        exit (1);
    }
    if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0) {
        perror ("failed to create socket");
        exit (1);
    }
    bzero ((char *) &s_addr, sizeof (s_addr));
    s_addr.sin_family = AF_INET;
    s_addr.sin_addr.s_addr = htonl (INADDR_ANY);
    s_addr.sin_port = htons (0);
    if (bind (s, (struct sockaddr *) &s_addr, sizeof (s_addr)) < 0) {
        perror ("bind failed");
        exit (2);
    }
    bzero ((char *) &c_addr, sizeof (c_addr));
    c_addr.sin_family = AF_INET;
    h = gethostbyname (argv[1]);
    if (h == NULL) {
        perror ("gethostbyname failed");
        exit (2);
    }
    bcopy (h->h_addr, &c_addr.sin_addr, h->h_length);
    c_addr.sin_port = htons (137);
    memcpy (ms, STATUS_REQ, sizeof (STATUS_REQ) -1);
    sz=sizeof (STATUS_REQ)-1;
    if (sendto (s, ms, sz, 0, &c_addr, sizeof (c_addr)) < 0) {
        perror ("sendto failed");
        exit (1);
    }
    signal (SIGALRM, sig_alrm);
    if (setjmp (env_alrm) != 0) {
        printf ("timeout\n");
        exit (1);
    }
    alarm (10);
    sz = recvfrom (s, ms, sizeof (ms), 0, (struct sockaddr *) 0, (int *)0);
    alarm (0);
    if (sz < 0) {
        perror ("recvfrom failed");
        exit (1);
    } else {
        printf ("received data:\n");
        dump_bytes (ms, sz, 0);
        dump_node_status (ms, sz);
    }
    return 0;
}
int
myisprint (int ch)
{
    return ((ch >= ' ') && (ch <= '~'));
}
static void
dump_bytes (unsigned char *p, size_t sz, int indent)
{
    while (sz > 16) {
        printf ("%*s%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X 
%02X %02X %02X %02X %02X  %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",
                indent, "",
                p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
                p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15],
                myisprint(p[0]) ? p[0] : '.',
                myisprint(p[1]) ? p[1] : '.',
                myisprint(p[2]) ? p[2] : '.',
                myisprint(p[3]) ? p[3] : '.',
                myisprint(p[4]) ? p[4] : '.',
                myisprint(p[5]) ? p[5] : '.',
                myisprint(p[6]) ? p[6] : '.',
                myisprint(p[7]) ? p[7] : '.',
                myisprint(p[8]) ? p[8] : '.',
                myisprint(p[9]) ? p[9] : '.',
                myisprint(p[10]) ? p[10] : '.',
                myisprint(p[11]) ? p[11] : '.',
                myisprint(p[12]) ? p[12] : '.',
                myisprint(p[13]) ? p[13] : '.',
                myisprint(p[14]) ? p[14] : '.',
                myisprint(p[15]) ? p[15] : '.');
        p+=16;
        sz -= 16;
    }
    if (sz) {
        char buf[17];
        int i = 0;
        int j = 16 - sz;
        memset (buf, 0, sizeof buf);
        printf ("%*s", indent, "");
        while (sz--) {
            printf ("%02X ", *p);
            if (myisprint (*p))
                buf[i++] = *p;
            else
                buf[i++] = '.';
            p++;
        }
        printf ("%*s%s\n", j*3 + 1, "", buf);
    }
}
typedef struct _node_status_resp {
  unsigned short trn_id __attribute__((packed));
  unsigned short flags1 __attribute__((packed));
  unsigned short flags2 __attribute__((packed));
  unsigned short flags3 __attribute__((packed));
  unsigned short flags4 __attribute__((packed));
  unsigned short flags5 __attribute__((packed));
  char rr_name[0x22] __attribute__((packed));
  unsigned short nbstat __attribute__((packed));  /* 0x0021 */
  unsigned short in __attribute__((packed));  /* 0x0001 */
  unsigned long zilch __attribute__((packed)); /* 0 */
  unsigned short rd_length __attribute__((packed));
  unsigned char num_names __attribute__((packed));
  struct {
    unsigned char nb_name[16] __attribute__((packed));
    unsigned short name_flags __attribute__((packed));
  } name_array[1] __attribute__((packed));
} NS_RESP;
#define NF_MASK_UG 128
#define NF_PATT_U  0
#define NF_PATT_G  128
struct _known_suffixes {
    unsigned char suff;
    unsigned short nf_mask;
    unsigned short nf_pattern;
    char *usage;
} Suffixes[] = {
    { 0x00, NF_MASK_UG, NF_PATT_U, "Workstation Service" },
    { 0x00, NF_MASK_UG, NF_PATT_G, "Domain Name" },
    { 0x01, NF_MASK_UG, NF_PATT_U, "Messenger Service" },
    { 0x01, NF_MASK_UG, NF_PATT_G, "Master Browser" },
    { 0x03, NF_MASK_UG, NF_PATT_U, "Messenger Service" },
    { 0x06, NF_MASK_UG, NF_PATT_U, "RAS Server Service" },
    { 0x1b, NF_MASK_UG, NF_PATT_U, "Domain Master Browser" },
    { 0x1c, NF_MASK_UG, NF_PATT_G, "Domain Controller" },
    { 0x1d, NF_MASK_UG, NF_PATT_U, "Master Browser" },
    { 0x1e, NF_MASK_UG, NF_PATT_G, "Potential Master Browser" },
    { 0x1f, NF_MASK_UG, NF_PATT_U, "NetDDE Service" },
    { 0x20, NF_MASK_UG, NF_PATT_U, "File Server Service" },
    { 0x21, NF_MASK_UG, NF_PATT_U, "RAS Client Service" },
    { 0x22, NF_MASK_UG, NF_PATT_U, "MS Exchange Interchange (MSMail)" },
    { 0x23, NF_MASK_UG, NF_PATT_U, "MS Exchange Store" },
    { 0x24, NF_MASK_UG, NF_PATT_U, "MS Exchange Directory" },
    { 0x2b, NF_MASK_UG, NF_PATT_U, "Lotus Notes Server" },
    { 0x2f, NF_MASK_UG, NF_PATT_G, "Lotus Notes" },
    { 0x30, NF_MASK_UG, NF_PATT_U, "Modem Sharing Server" },
    { 0x31, NF_MASK_UG, NF_PATT_U, "Modem Sharing Client" },
    { 0x33, NF_MASK_UG, NF_PATT_G, "Lotus Notes" },
    { 0x43, NF_MASK_UG, NF_PATT_U, "SMS Clients Remote Control" },
    { 0x44, NF_MASK_UG, NF_PATT_U, "SMS Administrators Remote Control Tool" 
},
    { 0x45, NF_MASK_UG, NF_PATT_U, "SMS Clients Remote Chat" },
    { 0x46, NF_MASK_UG, NF_PATT_U, "SMS Clients Remote Transfer" },
    { 0x4c, NF_MASK_UG, NF_PATT_U, "DEC Pathworks TCPIP service" },
    { 0x52, NF_MASK_UG, NF_PATT_U, "DEC Pathworks TCPIP service" },
    { 0x87, NF_MASK_UG, NF_PATT_U, "MS Exchange MTA" },
    { 0x6a, NF_MASK_UG, NF_PATT_U, "MS Exchange IMC" },
    { 0xbe, NF_MASK_UG, NF_PATT_U, "Network Monitor Agent" },
    { 0xbf, NF_MASK_UG, NF_PATT_U, "Network Monitor Application" },
};
#define NUM_SUFFIX  (sizeof (Suffixes) / sizeof (Suffixes[0]))
static void
dump_node_status (unsigned char *p, size_t sz)
{
    NS_RESP *r = (NS_RESP *)p;
    int i, j;
    if (sz < sizeof (*r)) {
        printf ("response too small\n");
        return;
    }
    printf ("%d names in response\n", r->num_names);
    if (sz < (sizeof (*r) + (r->num_names -1) * sizeof (r->name_array[0]))) 
{
        printf ("response too small for num_names\n");
        return;
    }
    for (i=0; i<r->num_names; i++) {
        printf (" %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c<0x%02x> %s", 
                myisprint (r->name_array[i].nb_name[0]) ? 
r->name_array[i].nb_name[0] : '.',
                myisprint (r->name_array[i].nb_name[1]) ? 
r->name_array[i].nb_name[1] : '.',
                myisprint (r->name_array[i].nb_name[2]) ? 
r->name_array[i].nb_name[2] : '.',
                myisprint (r->name_array[i].nb_name[3]) ? 
r->name_array[i].nb_name[3] : '.',
                myisprint (r->name_array[i].nb_name[4]) ? 
r->name_array[i].nb_name[4] : '.',
                myisprint (r->name_array[i].nb_name[5]) ? 
r->name_array[i].nb_name[5] : '.',
                myisprint (r->name_array[i].nb_name[6]) ? 
r->name_array[i].nb_name[6] : '.',
                myisprint (r->name_array[i].nb_name[7]) ? 
r->name_array[i].nb_name[7] : '.',
                myisprint (r->name_array[i].nb_name[8]) ? 
r->name_array[i].nb_name[8] : '.',
                myisprint (r->name_array[i].nb_name[9]) ? 
r->name_array[i].nb_name[9] : '.',
                myisprint (r->name_array[i].nb_name[10]) ? 
r->name_array[i].nb_name[10] : '.',
                myisprint (r->name_array[i].nb_name[11]) ? 
r->name_array[i].nb_name[11] : '.',
                myisprint (r->name_array[i].nb_name[12]) ? 
r->name_array[i].nb_name[12] : '.',
                myisprint (r->name_array[i].nb_name[13]) ? 
r->name_array[i].nb_name[13] : '.',
                myisprint (r->name_array[i].nb_name[14]) ? 
r->name_array[i].nb_name[14] : '.',
                r->name_array[i].nb_name[15],
                (r->name_array[i].name_flags & 128) ? "Group " : "Unique");
        for (j=0; j<NUM_SUFFIX; j++) {
            if ((r->name_array[i].nb_name[15] == Suffixes[j].suff)
                && ((r->name_array[i].name_flags & Suffixes[j].nf_mask)
                    == Suffixes[j].nf_pattern)) {
                printf ("  %s", Suffixes[j].usage);
                break;
            }
        }
        printf ("\n");
    }
}
static void
sig_alrm (int signo)
{
    longjmp (env_alrm, 1);
}
 [fine sorgente]

linux?
Purtroppo non so cosa fa NBTSTAT -A, non ho sistemi Win a portata di mano.
Per quanto riguarda il NET VIEW, usa:
smbclient -L <hostname>
(cmq un bel man nmblookup e man smbclient non guasta ;) )
