mirror of
https://github.com/Astatin3/unshell-nodes-rs.git
synced 2026-06-08 16:18:08 -06:00
Work on server and client connectivity
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
use std::{
|
||||
error::Error,
|
||||
mem,
|
||||
net::SocketAddr,
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use unshell_rs_lib::networkers::{ClientTrait, Connection, TCPClient, TCPConnection};
|
||||
|
||||
use crate::packets::{GuiPacket, Parameter, Parameters};
|
||||
|
||||
pub struct UnshellClient {
|
||||
addr: SocketAddr,
|
||||
client: Arc<Mutex<TCPConnection>>,
|
||||
|
||||
parameters: Arc<Mutex<Parameters>>,
|
||||
outgoing_packets: Arc<Mutex<Vec<GuiPacket>>>,
|
||||
}
|
||||
|
||||
impl UnshellClient {
|
||||
pub fn new(addr: SocketAddr) -> Result<Self, Box<dyn Error>> {
|
||||
let client = Arc::new(Mutex::new(TCPClient::connect(&addr)?));
|
||||
let outgoing_packets = Arc::new(Mutex::new(Vec::<GuiPacket>::new()));
|
||||
let parameters = Arc::new(Mutex::new(Parameters::new()));
|
||||
|
||||
let tx_client = Arc::clone(&client);
|
||||
let tx_packets = Arc::clone(&outgoing_packets);
|
||||
|
||||
// Recieve thread
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
info!("Lock 2");
|
||||
let mut packets_lock = tx_packets.lock().unwrap();
|
||||
info!("Lock 2");
|
||||
if !packets_lock.is_empty() {
|
||||
info!("Lock 3");
|
||||
if let Ok(packet) = packets_lock.pop().unwrap().encode() {
|
||||
info!("Lock 3");
|
||||
let mut client_lock = tx_client.lock().unwrap();
|
||||
info!("Wrote {}", packet.as_str());
|
||||
match client_lock.write(packet.as_str()) {
|
||||
Err(e) => {
|
||||
error!("Failed to send packet: {:?}", e);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
std::mem::drop(packets_lock);
|
||||
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
});
|
||||
|
||||
let rx_client = Arc::clone(&client);
|
||||
let rx_params = Arc::clone(¶meters);
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
info!("Lock 4");
|
||||
let mut client = rx_client.lock().unwrap();
|
||||
info!("Lock 4");
|
||||
if !client.is_alive() {
|
||||
error!("Disconnected from {}!", client.get_info());
|
||||
}
|
||||
if let Ok(data) = client.read() {
|
||||
info!("Got {}", data);
|
||||
if let Ok(packet) = GuiPacket::decode(data.as_str()) {
|
||||
match packet {
|
||||
GuiPacket::ParameterUpate(name, parameter) => {
|
||||
rx_params.lock().unwrap().insert(name, parameter);
|
||||
}
|
||||
GuiPacket::Error(error_packet) => {
|
||||
error!("Got error: {}", print_type_of(&error_packet))
|
||||
}
|
||||
GuiPacket::SetAllParameters(parameters) => {
|
||||
let mut params_lock = rx_params.lock().unwrap();
|
||||
params_lock.clear();
|
||||
params_lock.extend(parameters);
|
||||
}
|
||||
_ => {
|
||||
error!("Unsupported packet: {}", data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// std::mem::drop(client);
|
||||
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
});
|
||||
|
||||
Ok(Self {
|
||||
addr,
|
||||
client,
|
||||
parameters,
|
||||
outgoing_packets,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_parameter(&mut self, key: String, param: Parameter) {
|
||||
self.parameters
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(key.clone(), param.clone());
|
||||
self.outgoing_packets
|
||||
.lock()
|
||||
.unwrap()
|
||||
.push(GuiPacket::SetParameter(key, param));
|
||||
}
|
||||
|
||||
pub fn get_parameter(&self, key: &str) -> Option<Parameter> {
|
||||
self.parameters.lock().unwrap().get(key).cloned()
|
||||
}
|
||||
}
|
||||
|
||||
fn print_type_of<T>(_: &T) -> &'static str {
|
||||
std::any::type_name::<T>()
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
use slint::{ComponentHandle, ModelRc, VecModel};
|
||||
use std::{
|
||||
error::Error,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use unshell_rs_lib::config::campaign::CampaignConfig;
|
||||
|
||||
use crate::{client::UnshellClient, packets::Parameter};
|
||||
|
||||
pub struct UnshellGui {
|
||||
client: UnshellClient,
|
||||
ui: AppWindow,
|
||||
campaign: Option<Arc<Mutex<CampaignConfig>>>,
|
||||
}
|
||||
|
||||
slint::include_modules!();
|
||||
impl UnshellGui {
|
||||
pub fn start(client: UnshellClient) -> Result<(), Box<dyn Error>> {
|
||||
let ui = AppWindow::new()?;
|
||||
let client = Arc::new(Mutex::new(client));
|
||||
|
||||
let ui_handle = ui.as_weak();
|
||||
let client_clone = Arc::clone(&client);
|
||||
ui.on_tab_clicked(move |index| {
|
||||
let ui = ui_handle.unwrap();
|
||||
ui.set_current_tab(index);
|
||||
info!("Lock 1 ");
|
||||
let mut client_lock = client_clone.lock().unwrap();
|
||||
info!("Lock 1 ");
|
||||
client_lock.set_parameter("Current Tab".to_string(), Parameter::CurrentTab(index));
|
||||
trace!("Tab {} selected", index);
|
||||
});
|
||||
|
||||
ui.set_app_info({
|
||||
(String::new()
|
||||
+ "Unshell\n"
|
||||
+ "Version "
|
||||
+ env!("CARGO_PKG_VERSION")
|
||||
+ "\n\n View the source code at:\n https://github.com/astatin3/unshell-rs")
|
||||
.into()
|
||||
});
|
||||
|
||||
ui.run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update(&mut self) {
|
||||
// self.ui.set_listeners(ModelRc::new(VecModel::from(
|
||||
// self.campaign
|
||||
// .listeners
|
||||
// .iter()
|
||||
// .map(|l| match l {
|
||||
// ListenerConfig::Tcp {
|
||||
// enabled,
|
||||
// name,
|
||||
// addr,
|
||||
// layers,
|
||||
// ..
|
||||
// } => UITcpListener {
|
||||
// enabled: *enabled,
|
||||
// name: name.clone().into(),
|
||||
// remote_host: addr.to_string().into(),
|
||||
// },
|
||||
// })
|
||||
// .collect::<Vec<UITcpListener>>(),
|
||||
// )));
|
||||
}
|
||||
}
|
||||
|
||||
// trait
|
||||
@@ -0,0 +1,6 @@
|
||||
mod gui;
|
||||
|
||||
mod client;
|
||||
|
||||
pub use client::UnshellClient;
|
||||
pub use gui::UnshellGui;
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
use slint::{ModelRc, VecModel};
|
||||
use std::error::Error;
|
||||
use unshell_rs_lib::config::listeners::ListenerConfig;
|
||||
|
||||
pub struct Unshell_Gui;
|
||||
|
||||
slint::include_modules!();
|
||||
impl Unshell_Gui {
|
||||
pub fn start() -> Result<Self, Box<dyn Error>> {
|
||||
let ui = AppWindow::new()?;
|
||||
|
||||
// ui.
|
||||
|
||||
let ui_handle = ui.as_weak();
|
||||
ui.on_tab_clicked(move |index| {
|
||||
let ui = ui_handle.unwrap();
|
||||
ui.set_current_tab(index);
|
||||
trace!("Tab {} selected", index);
|
||||
});
|
||||
|
||||
ui.set_app_info({
|
||||
(String::new()
|
||||
+ "Unshell\n"
|
||||
+ "Version "
|
||||
+ env!("CARGO_PKG_VERSION")
|
||||
+ "\n\n View the source code at:\n https://github.com/astatin3/unshell-rs")
|
||||
.into()
|
||||
});
|
||||
|
||||
let listeners: Vec<ListenerConfig> = vec![ListenerConfig::Tcp {
|
||||
enabled: true,
|
||||
name: "test".to_string(),
|
||||
remote_host: "127.0.0.1".to_string(),
|
||||
port: 25565,
|
||||
layers: Vec::new(),
|
||||
}];
|
||||
|
||||
ui.set_listeners(ModelRc::new(VecModel::from(
|
||||
listeners
|
||||
.iter()
|
||||
.map(|l| match l {
|
||||
ListenerConfig::Tcp {
|
||||
enabled,
|
||||
name,
|
||||
remote_host,
|
||||
port,
|
||||
layers,
|
||||
} => UITcpListener {
|
||||
enabled: *enabled,
|
||||
name: name.clone().into(),
|
||||
remote_host: remote_host.clone().into(),
|
||||
port: *port as i32,
|
||||
},
|
||||
})
|
||||
.collect::<Vec<UITcpListener>>(),
|
||||
)));
|
||||
|
||||
ui.run()?;
|
||||
|
||||
Ok(Self {})
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -1,5 +1,10 @@
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
mod gui;
|
||||
mod client;
|
||||
mod packets;
|
||||
mod server;
|
||||
|
||||
pub use client::UnshellClient;
|
||||
pub use client::UnshellGui;
|
||||
pub use server::UnshellServer;
|
||||
|
||||
+75
-33
@@ -1,19 +1,25 @@
|
||||
use std::error::Error;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use log::trace;
|
||||
use slint::{ModelRc, VecModel};
|
||||
use unshell_rs_lib::{
|
||||
config::listeners::ListenerConfig,
|
||||
listeners::Listener,
|
||||
networkers::{ServerTrait, TCPServer},
|
||||
use std::{
|
||||
env,
|
||||
error::Error,
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
/// The default port that this program looks for
|
||||
use clap::{Parser, Subcommand};
|
||||
use log::error;
|
||||
use unshell_rs::{UnshellClient, UnshellGui, UnshellServer};
|
||||
// use unshell_rs
|
||||
|
||||
pub static DEFAULT_CONFIG_FILEPATH: &'static str = "server_config.json";
|
||||
|
||||
// The default port that this program looks for
|
||||
pub static DEFAULT_SERVICE_PORT: u16 = 13370;
|
||||
/// The default website port that this program looks for
|
||||
// The default website port that this program looks for
|
||||
pub static DEFAULT_WEB_PORT: u16 = 8082;
|
||||
|
||||
pub static LOCAL_SOCKET: SocketAddr =
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 12, 34, 56)), 13370);
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "unshell-rs")]
|
||||
#[command(about = "Slick reverse shell tool in rust", long_about = None)]
|
||||
@@ -26,48 +32,84 @@ struct Args {
|
||||
enum Commands {
|
||||
/// Run as a service, and potentially hosting a website
|
||||
#[command(arg_required_else_help = true)]
|
||||
Serve {
|
||||
/// Only listen for command clients locally
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
local: bool,
|
||||
Server {
|
||||
/// IPv4 to listen for clients on.
|
||||
host: String,
|
||||
|
||||
/// Port listen to for command clients
|
||||
#[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)]
|
||||
service_port: u16,
|
||||
port: u16,
|
||||
|
||||
/// Json file to store config
|
||||
#[arg(short, long, default_value_t = DEFAULT_CONFIG_FILEPATH.to_string())]
|
||||
config_filepath: String,
|
||||
// /// Port to listen for website traffic (0 is disabled)
|
||||
// #[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)]
|
||||
// web_port: u16,
|
||||
},
|
||||
Gui {
|
||||
/// Listen for command clients remotely aswell
|
||||
#[arg(short, long, default_value_t = true)]
|
||||
remote: bool,
|
||||
/// Run GUI and connect to remote server
|
||||
Remote {
|
||||
/// Remote server to connect to
|
||||
host: String,
|
||||
|
||||
/// Port listen to for command clients
|
||||
#[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)]
|
||||
service_port: u16,
|
||||
port: u16,
|
||||
},
|
||||
/// Run both server and GUI on local machine.
|
||||
Local {
|
||||
/// Json file to store config
|
||||
#[arg(short, long, default_value_t = DEFAULT_CONFIG_FILEPATH.to_string())]
|
||||
config_filepath: String,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
if env::var("RUST_LOG").is_err() {
|
||||
unsafe { env::set_var("RUST_LOG", "info") }
|
||||
}
|
||||
|
||||
pretty_env_logger::init();
|
||||
let args = Args::parse();
|
||||
|
||||
match args.command {
|
||||
Commands::Gui {
|
||||
remote,
|
||||
service_port,
|
||||
} => {}
|
||||
Commands::Serve {
|
||||
local,
|
||||
service_port,
|
||||
// web_port,
|
||||
} => {}
|
||||
}
|
||||
Commands::Local { config_filepath } => {
|
||||
let mut server = UnshellServer::from_filepath(config_filepath.as_str());
|
||||
server.run(LOCAL_SOCKET)?;
|
||||
|
||||
// let mut server = Listener::new(TCPServer::bind("0.0.0.0:3000")?);
|
||||
let client = UnshellClient::new(LOCAL_SOCKET)?;
|
||||
|
||||
// server.run_listener()?;
|
||||
UnshellGui::start(client)?;
|
||||
}
|
||||
Commands::Remote { host, port } => {
|
||||
let addr = SocketAddr::from_str(format!("{}:{}", host, port).as_str());
|
||||
let client = UnshellClient::new(if let Ok(addr) = addr {
|
||||
addr
|
||||
} else {
|
||||
error!("Could not parse address!");
|
||||
return Ok(());
|
||||
})?;
|
||||
|
||||
UnshellGui::start(client)?;
|
||||
}
|
||||
Commands::Server {
|
||||
host,
|
||||
port,
|
||||
config_filepath,
|
||||
} => {
|
||||
let mut unshell_server = UnshellServer::from_filepath(config_filepath.as_str());
|
||||
|
||||
let addr = SocketAddr::from_str(format!("{}:{}", host, port).as_str());
|
||||
if let Ok(addr) = addr {
|
||||
unshell_server.run(addr)?;
|
||||
} else {
|
||||
error!("Could not parse address!");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
use serde_json::Result;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use unshell_rs_lib::connection::ErrorPacket;
|
||||
|
||||
pub type Parameters = HashMap<String, Parameter>;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum GuiPacket {
|
||||
GetParameter(String),
|
||||
AckGetParameter(String, Option<Parameter>),
|
||||
ParameterUpate(String, Parameter),
|
||||
|
||||
SetParameter(String, Parameter),
|
||||
AckSetParameter(bool),
|
||||
|
||||
SetAllParameters(Parameters),
|
||||
|
||||
Error(ErrorPacket),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum Parameter {
|
||||
Test1,
|
||||
CurrentTab(i32),
|
||||
}
|
||||
|
||||
impl GuiPacket {
|
||||
pub fn encode(&self) -> Result<String> {
|
||||
serde_json::to_string(self)
|
||||
}
|
||||
|
||||
pub fn decode(string: &str) -> Result<Self> {
|
||||
serde_json::from_str::<Self>(string)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
use lazy_static::lazy_static;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use unshell_rs_lib::config::campaign::CampaignConfig;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::packets::Parameters;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref DEFAULT_CAMPAIGN: CampaignConfig = CampaignConfig {
|
||||
name: "Default Campaign".to_string(),
|
||||
listeners: Vec::new(),
|
||||
};
|
||||
pub static ref DEFAULT_USERS: Vec<User> = vec![User {
|
||||
name: "User".into(),
|
||||
key: "CHANGEME".to_string(),
|
||||
}];
|
||||
pub static ref DEFAULT_PARAMETERS: Parameters = {
|
||||
let p = Parameters::new();
|
||||
|
||||
p
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct User {
|
||||
pub name: String,
|
||||
pub key: String,
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
mod config;
|
||||
mod server;
|
||||
|
||||
pub use crate::server::config::{DEFAULT_CAMPAIGN, DEFAULT_USERS, User};
|
||||
|
||||
pub use server::UnshellServer;
|
||||
@@ -0,0 +1,153 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error::Error,
|
||||
fs::File,
|
||||
io::Read,
|
||||
net::SocketAddr,
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use unshell_rs_lib::{
|
||||
config::campaign::CampaignConfig,
|
||||
connection::ErrorPacket,
|
||||
networkers::{Connection, ServerTrait, TCPConnection, TCPServer, run_listener_state},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
packets::{GuiPacket, Parameters},
|
||||
server::{DEFAULT_CAMPAIGN, DEFAULT_USERS, User, config::DEFAULT_PARAMETERS},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct UnshellServerConfig {
|
||||
campaign: CampaignConfig,
|
||||
parameters: Parameters,
|
||||
users: Vec<User>,
|
||||
|
||||
#[serde(skip)]
|
||||
client_count: usize,
|
||||
#[serde(skip)]
|
||||
broadcast_flag: HashMap<usize, Option<String>>,
|
||||
}
|
||||
|
||||
pub struct UnshellServer {
|
||||
config: Arc<Mutex<UnshellServerConfig>>,
|
||||
}
|
||||
|
||||
impl UnshellServer {
|
||||
pub fn from_filepath(filepath: &str) -> Self {
|
||||
(|| -> Result<Self, Box<dyn Error>> {
|
||||
let mut file = File::open(filepath.to_string())?;
|
||||
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)?;
|
||||
|
||||
let config = serde_json::from_str::<UnshellServerConfig>(contents.as_str())?;
|
||||
|
||||
info!("Loaded server config from {}", filepath);
|
||||
|
||||
Ok(Self {
|
||||
config: Arc::new(Mutex::new(config)),
|
||||
})
|
||||
})()
|
||||
.unwrap_or({
|
||||
warn!("Loaded default server config");
|
||||
Self {
|
||||
config: Arc::new(Mutex::new(UnshellServerConfig {
|
||||
campaign: DEFAULT_CAMPAIGN.clone(),
|
||||
users: DEFAULT_USERS.clone(),
|
||||
parameters: DEFAULT_PARAMETERS.clone(),
|
||||
|
||||
client_count: 0,
|
||||
broadcast_flag: HashMap::new(),
|
||||
})),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn run(&mut self, addr: SocketAddr) -> Result<(), Box<dyn Error>> {
|
||||
let on_connect = |connection: TCPConnection,
|
||||
config_clone: Arc<Mutex<UnshellServerConfig>>| {
|
||||
// Recieve loop
|
||||
thread::spawn(move || {
|
||||
let config = Arc::clone(&config_clone);
|
||||
|
||||
let mut connection = connection;
|
||||
|
||||
let send = |c: &mut TCPConnection, packet: GuiPacket| {
|
||||
if let Ok(packet) = packet.encode() {
|
||||
info!("Send {}", packet);
|
||||
c.write(packet.as_str()).unwrap();
|
||||
}
|
||||
};
|
||||
|
||||
let mut config_lock = config.lock().unwrap();
|
||||
let client_id = config_lock.client_count.clone();
|
||||
config_lock.client_count += 1;
|
||||
send(
|
||||
&mut connection,
|
||||
GuiPacket::SetAllParameters(config_lock.parameters.clone()),
|
||||
);
|
||||
std::mem::drop(config_lock);
|
||||
|
||||
loop {
|
||||
if !connection.is_alive() {
|
||||
warn!("Client {} disconnected!", connection.get_info());
|
||||
break;
|
||||
}
|
||||
if let Ok(data) = connection.read() {
|
||||
if let Ok(packet) = GuiPacket::decode(data.as_str()) {
|
||||
match packet {
|
||||
GuiPacket::GetParameter(param) => send(
|
||||
&mut connection,
|
||||
GuiPacket::AckGetParameter(param.clone(), {
|
||||
let config_lock = config.lock().unwrap();
|
||||
let result = config_lock.parameters.get(¶m);
|
||||
result.cloned()
|
||||
}),
|
||||
),
|
||||
GuiPacket::SetParameter(name, param) => send(
|
||||
&mut connection,
|
||||
GuiPacket::AckSetParameter({
|
||||
let mut config_lock = config.lock().unwrap();
|
||||
config_lock.parameters.insert(name.clone(), param);
|
||||
config_lock.broadcast_flag.insert(client_id, Some(name));
|
||||
|
||||
true
|
||||
}),
|
||||
),
|
||||
_ => send(
|
||||
&mut connection,
|
||||
GuiPacket::Error(ErrorPacket::UnsupportedRequestError),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut config_lock = config.lock().unwrap();
|
||||
if let Some(Some(key)) = config_lock.broadcast_flag.get(&client_id) {
|
||||
send(
|
||||
&mut connection,
|
||||
GuiPacket::ParameterUpate(
|
||||
key.clone(),
|
||||
config_lock.parameters.get(key).unwrap().clone(),
|
||||
),
|
||||
);
|
||||
config_lock.broadcast_flag.insert(client_id, None);
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let config_clone = Arc::clone(&self.config);
|
||||
run_listener_state(TCPServer::bind(&addr)?, on_connect, config_clone);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user