Mostrando las entradas con la etiqueta programacion. Mostrar todas las entradas
Mostrando las entradas con la etiqueta programacion. Mostrar todas las entradas

25 nov 2014

Consultas WMI



Genérica
Set objWMIService = GetObject("winmgmts:\\" & host & "\root\cimv2")
Registro
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & host & "\root\default:StdRegProv")
Políticas
Set objRsop=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & host & "\root\rsop\computer")

Usuarios locales: "Select * from Win32_UserAccount Where LocalAccount = True"
Grupos locales: "Select * from Win32_Group  Where LocalAccount = True"
Usuarios dentro de un grupo: SELECT * FROM Win32_GroupUser WHERE (groupcomponent = 'win32_group.name="Administrators",domain="MyHostName"')
Informacion de un User Profile: "Select * From Win32_UserProfile"
Servicios: "Select * from Win32_Service"
Shares: "Select * from Win32_Share"

Politicas

"select * from RSOP_SecuritySettingNumeric where precedence=1"
"Select * from RSOP_UserPrivilegeRight where precedence=1"
"Select * from RSOP_PolicySetting where precedence=1"
"Select * from RSOP_AuditPolicy where precedence=1"

5 feb 2012

plugin en python para xchat : whois automatico

Un poco de código, es un script para xchat que hace que al momento de abrir un privado automáticamente muestra la información "whois" de la persona con quien se esta chateando. El script es muy simple y me sirve para encontrar otros canales que quizas puedan interesarme en Freenode. Lo he programado en ubuntu 11.10 y xchat 2.8.8.

Para mayor informacion de como extender las funcionalidades de xchat:
http://xchat.org/docs/ 


'''
Created on 04/02/2012
querywhois.py
@author: christian
cquispe.dev@gmail.com
'''
__module_name__ = "querywhois"
__module_version__ = "1.0"
__module_description__ = "muestra la informacion de whois del otro usuario cuando se abre o recibe un mensaje privado. Probado en xchat 2.8.8"
__module_author__ = "Christian "

import xchat #@UnresolvedImport

def mensaje_nuevo(word, word_eol, userdata):
    cntx = xchat.get_context()
    user = cntx.get_info("channel")
    if user[0] != "#":
        cntx.command("whois " + user)
    return xchat.EAT_NONE

def whois_info(word, word_eol, userdata):
    #print word
    cntx = xchat.find_context(channel = word[0])
    if cntx is None:
        #para cuando se hace whois sin abrir privado, lo envia a la salida normal
        cntx = xchat.get_context()
    cntx.prnt(" ".join(word))
    return xchat.EAT_XCHAT

#capturamos todos los eventos de whois 
WHOIS_EVENTS = [
                "WhoIs Authenticated",
                "WhoIs Away Line",
                "WhoIs Channel/Oper Line",
                "WhoIs End",
                "WhoIs Identified",
                "WhoIs Idle Line",
                "WhoIs Idle Line with Signon",
                "WhoIs Name Line",
                "WhoIs Real Host",
                "WhoIs Server Line",
                "WhoIs Special"
              ]
for whois_event in WHOIS_EVENTS:
    xchat.hook_print(whois_event, whois_info)

# xchat.hook_print("WhoIs Channel/Oper Line", whois_info)
# xchat.hook_print("WhoIs Authenticated", whois_info)
# xchat.hook_print("WhoIs Away Line", whois_info)
# xchat.hook_print("WhoIs End", whois_info)
# xchat.hook_print("WhoIs Identified", whois_info)
# xchat.hook_print("WhoIs Idle Line with Signon", whois_info)
# xchat.hook_print("WhoIs Idle Line", whois_info)
# xchat.hook_print("WhoIs Name Line", whois_info)
# xchat.hook_print("WhoIs Real Host", whois_info)
# xchat.hook_print("WhoIs Server Line", whois_info)
# xchat.hook_print("WhoIs Special", whois_info)

#captura los eventos de creacion de ventana, cuando se hace abre o recibe un privado
#Open Context esta mencionado en la documentacion de plugin de C++ pero no en la de python
xchat.hook_print("Open Context", mensaje_nuevo)

print "querywhois loaded"

31 oct 2008

Instalando ns-3, Network Simulator Version 3

Aqui podemos encontrar la descripcion completa, tutoriales.
http://www.nsnam.org/

Una descripcion de ns-3
http://www.nsnam.org/docs/ns-3-overview.pdf

Instalando los prerequisitos:
aptitude install gccxml sqlite3 build-essential libsqlite3-dev libgoocanvas-dev libgoocanvas3 unzip python-dev gcc-3.4 gcc-4.1 libgtk2.0-0 libgtk2.0-dev doxygen graphviz imagemagick texinfo dia flex bison tcpdump wireshark

pygccxml

wget http://downloads.sourceforge.net/pygccxml/pygccxml-1.0.0.zip?modtime=1224497206&big_mirror=0
unzip pygccxml-1.0.0.zip
cd pygccxml-1.0.0
python setup.py install
cd ..

Descargamos e instalamos ns-3:
wget http://www.nsnam.org/releases/ns-3.2.tar.bz2
tar jxvf ns-3.2.tar.bz2
cd ns-3.2
./waf configure
./waf

Terminado de compilar podemos comprobar si a sido correcta la compilacion
./waf check
Generamos la documentacion:
./waf --doxygen

23 oct 2008

Configurando emacs para autocompletado, resaltado de sintaxis y otras cosas

Actualmente estoy en la tarea de usar emacs, para programar.
Falta mejorar varias cosas, pero por el momento mi archivo de configuracion .emacs esta quedando asi:



(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(current-language-environment "UTF-8")
'(display-time-mode t)
'(ecb-options-version "2.32")
'(global-font-lock-mode t nil (font-lock))
'(global-semantic-stickyfunc-mode nil nil (semantic-util-modes))
'(safe-local-variable-values (quote ((indent-tabs-mode . 1))))
'(semantic-idle-scheduler-idle-time 3)
'(tab-width 4))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

(require 'cc-mode)
(setq c-default-style "bsd"
c-basic-offset 4)
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backups"))))
;; turn on paren matching
(show-paren-mode t)
(setq show-paren-style 'mixed)

;; Use "y or n" answers instead of full words "yes or no"
(fset 'yes-or-no-p 'y-or-n-p)
;; Display the time in the mode line
(setq display-time-24hr-format t)
(display-time)


(setq truncate-partial-width-windows nil)
(setq after-save-hook (quote (executable-make-buffer-file-executable-if-script-p)))
;; para asegurarte de que el fichero termina con línea vacía
(setq require-final-newline 'ask)
;;
;; eliminar espacios en blanco a final de línea y líneas vacias al final
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
(setq delete-trailing-whitespace-p t)


;;Auto-añadir paréntesis o llave de cierre
(setq skeleton-pair t)
(global-set-key "[" 'skeleton-pair-insert-maybe)
(global-set-key "(" 'skeleton-pair-insert-maybe)
(global-set-key "{" 'skeleton-pair-insert-maybe)
(global-set-key "'" 'skeleton-pair-insert-maybe)
(global-set-key "\"" 'skeleton-pair-insert-maybe)

(require 'semantic nil t)
(global-semantic-idle-scheduler-mode 1)
(global-semantic-idle-completions-mode 1)
(global-semantic-idle-summary-mode 1)
(require 'semantic-sb nil t)
(require 'semanticdb nil t)

(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)

;; Load CEDET
;; (load-file "~/cedet-VERSION/common/cedet.el")
;;
;; Enabling various SEMANTIC minor modes. See semantic/INSTALL for more ideas.
;; Select one of the following:

;; * This enables the database and idle reparse engines
(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;; imenu support, and the semantic navigator
(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as the nascent intellisense mode
;; decoration mode, and stickyfunc mode (plus regular code helpers)
(semantic-load-enable-guady-code-helpers)

;; * This turns on which-func support (Plus all other code helpers)
(semantic-load-enable-excessive-code-helpers)

;; This turns on modes that aid in grammar writing and semantic tool
;; development. It does not enable any other features such as code
;; helpers above.
(semantic-load-enable-semantic-debugging-helpers)
(which-func-mode t)


(require 'semantic-ia nil t)
(global-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
(global-set-key [(control shift return)] 'semantic-ia-complete-symbol)

(setq semanticdb-default-save-directory "~/.emacs.d/semantic")

(setq semantic-load-turn-everything-on t)
(require 'semantic-load)
(global-semantic-show-unmatched-syntax-mode -1)

(require 'ctypes)
(turn-on-font-lock)
(ctypes-auto-parse-mode 1)


(require 'ecb)
(require 'ecb-autoloads)
(setq ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
;; Desactivamos el Tip of the Day de ECB...
(setq ecb-tip-of-the-day nil)
(ecb-activate)

(global-set-key [f12] 'ecb-toggle-ecb-windows)
(global-set-key [C-f12] 'ecb-activate)
(global-set-key [M-f12] 'ecb-deactivate)

(setq tex-dvi-view-command "xdvi")
;;(transient-mark-mode 1)
;;(add-hook 'text-mode-hook 'turn-on-auto-fill)




(setq-default TeX-master nil)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(load "preview-latex.el" nil t t)


(defalias 'perl-mode 'cperl-mode)






11 sept 2008

Resolviendo nombres dns de manera independiente del protocolo

Este es un ejemplo del uso de la funcion getaddrinfo , la cual nos permite resolver nombres de host a ip, de forma independiente del protocolo( Ipv4 o IPv6).
No se porq no se muestra los includes.


#define
#define
#define
#define

#define MAXSOCK 20

int main(int argc, char **argv)
{
int error=0;
struct addrinfo hints, *res, *res0;

memset(&hints, 0, sizeof(hints));
hints.ai_socktype= 0;//SOCK_STREAM;

if(argc!=2)
fprintf(stderr,"modo de uso: dns_resolve fqdn\n");
else
{
error = getaddrinfo(argv[1],NULL,&hints,&res0);
if(error)//si es diferente de cero
{
fprintf(stderr,"dns_resolve %s: %s\n",argv[1],gai_strerror(error));
}
else
{
for(res=res0; res ; res=res->ai_next)
{
int error;
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
switch (res->ai_family) {
case AF_INET:
printf("Interfaz IPv4 %d\n", res->ai_family);
break;
case AF_INET6:
printf("Interfaz IPv6 %d\n", res->ai_family);
break;
default:
printf("interfaz desconocida \n");
return 1;
break;
}
error = getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if(error)//si es diferente de cero
{
fprintf(stderr,"error dns_resolve: %s\n",gai_strerror(error));
}
printf("addr: %s port: %s\n",hbuf,sbuf);
}
}
}
return 1;
}