Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/proto/ipmi/utils.rb
Views: 11704
# -*- coding: binary -*-12module Rex3module Proto4module IPMI5class Utils67def self.checksum(data)8sum = 09data.unpack("C*").each {|c| sum += c }10sum = ~sum + 111sum & 0xff12end1314def self.create_ipmi_getchannel_probe15[ # Get Channel Authentication Capabilities160x06, 0x00, 0xff, 0x07, # RMCP Header170x00, 0x00, 0x00, 0x00,180x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x20, 0x18,190xc8, 0x81, 0x00, 0x38, 0x8e, 0x04, 0xb520].pack("C*")21end2223# open rmcpplus_request24def self.create_ipmi_session_open_request(console_session_id)25head = [260x06, 0x00, 0xff, 0x07, # RMCP Header270x06, # RMCP+ Authentication Type28PAYLOAD_RMCPPLUSOPEN_REQ, # Payload Type290x00, 0x00, 0x00, 0x00, # Session ID300x00, 0x00, 0x00, 0x00 # Sequence Number31].pack("C*")3233data =34[ # Maximum access350x00, 0x00,36# Reserved370x00, 0x0038].pack("C*") +39console_session_id +40[410x00, 0x00, 0x00, 0x08,420x01, 0x00, 0x00, 0x00,430x01, 0x00, 0x00, 0x08,44# HMAC-SHA1450x01, 0x00, 0x00, 0x00,460x02, 0x00, 0x00, 0x08,47# AES Encryption480x01, 0x00, 0x00, 0x0049].pack("C*")5051head + [data.length].pack('v') + data52end535455# open rmcpplus_request with cipherzero56def self.create_ipmi_session_open_cipher_zero_request(console_session_id)57head = [580x06, 0x00, 0xff, 0x07, # RMCP Header590x06, # RMCP+ Authentication Type60PAYLOAD_RMCPPLUSOPEN_REQ, # Payload Type610x00, 0x00, 0x00, 0x00, # Session ID620x00, 0x00, 0x00, 0x00 # Sequence Number63].pack("C*")6465data =66[ # Maximum access670x00, 0x00,68# Reserved690x00, 0x0070].pack("C*") +71console_session_id +72[730x00, 0x00, 0x00, 0x08,74# Cipher 0750x00, 0x00, 0x00, 0x00,760x01, 0x00, 0x00, 0x08,77# Cipher 0780x00, 0x00, 0x00, 0x00,790x02, 0x00, 0x00, 0x08,80# No Encryption810x00, 0x00, 0x00, 0x0082].pack("C*")8384head + [data.length].pack('v') + data85end8687def self.create_ipmi_rakp_1(bmc_session_id, console_random_id, username)88head = [890x06, 0x00, 0xff, 0x07, # RMCP Header900x06, # RMCP+ Authentication Type91PAYLOAD_RAKP1, # Payload Type920x00, 0x00, 0x00, 0x00,930x00, 0x00, 0x00, 0x00,94].pack("C*")9596data =97[0x00, 0x00, 0x00, 0x00].pack("C*") +98bmc_session_id +99console_random_id +100[1010x14, 0x00, 0x00,102username.length103].pack("C*") +104username105106head + [data.length].pack('v') + data107end108109110def self.create_rakp_hmac_sha1_salt(con_sid, bmc_sid, con_rid, bmc_rid, bmc_gid, auth_level, username)111con_sid +112bmc_sid +113con_rid +114bmc_rid +115bmc_gid +116[ auth_level ].pack("C") +117[ username.length ].pack("C") +118username119end120121def self.verify_rakp_hmac_sha1(salt, hash, password)122OpenSSL::HMAC.digest('sha1', password, salt) == hash123end124125end126end127end128end129130131